主播卡片头像跳转、左右震动动画
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
#import "XPNewUserRechargeSucessView.h"
|
||||
#import "XPTaskCompleteTipView.h"
|
||||
#import "XPWebViewController.h"
|
||||
#import "XPMineUserInfoViewController.h"
|
||||
///Present
|
||||
#import "MainPresenter.h"
|
||||
#import "MainProtocol.h"
|
||||
@@ -143,7 +144,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
[self.selectedViewController.navigationController presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
if (self.needShowAnchorCard && !self.delayShowAnchorCard) {
|
||||
[self.presenter getAnchorCardInfo];;
|
||||
[self.presenter getAnchorCardInfo];
|
||||
}
|
||||
if (self.secondLaunchShowAnchorCard) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@@ -257,6 +258,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
||||
[UIView animateWithDuration:0.5 animations:^{
|
||||
self.anchorCardView.frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 90);
|
||||
} completion:^(BOOL finished) {
|
||||
if (finished) {
|
||||
[self shakeAction];
|
||||
}
|
||||
}];
|
||||
self.anchorCardView.cardInfo = cardInfo;
|
||||
[self.view addSubview:self.anchorCardView];
|
||||
@@ -266,6 +271,36 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
}
|
||||
}
|
||||
|
||||
///主播卡片震动动画
|
||||
- (void)shakeAction {
|
||||
// 晃动次数
|
||||
static int numberOfShakes = 4;
|
||||
// 晃动幅度(相对于总宽度)
|
||||
static float vigourOfShake = 0.04f;
|
||||
// 晃动延续时常(秒)
|
||||
static float durationOfShake = 0.5f;
|
||||
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
|
||||
//关键帧(点)
|
||||
CGPoint layerPosition = self.anchorCardView.layer.position;
|
||||
// 起始点
|
||||
NSValue *value1 = [NSValue valueWithCGPoint:self.anchorCardView.layer.position];
|
||||
// 关键点数组
|
||||
NSMutableArray *values = [[NSMutableArray alloc] initWithObjects:value1, nil];
|
||||
for (int i = 0; i<numberOfShakes; i++) {
|
||||
// 左右晃动的点
|
||||
NSValue *valueLeft = [NSValue valueWithCGPoint:CGPointMake(layerPosition.x-self.anchorCardView.frame.size.width*vigourOfShake*(1-(float)i/numberOfShakes), layerPosition.y)];
|
||||
NSValue *valueRight = [NSValue valueWithCGPoint:CGPointMake(layerPosition.x+self.anchorCardView.frame.size.width*vigourOfShake*(1-(float)i/numberOfShakes), layerPosition.y)];
|
||||
|
||||
[values addObject:valueLeft];
|
||||
[values addObject:valueRight];
|
||||
}
|
||||
// 最后回归到起始点
|
||||
[values addObject:value1];
|
||||
shakeAnimation.values = values;
|
||||
shakeAnimation.duration = durationOfShake;
|
||||
[self.anchorCardView.layer addAnimation:shakeAnimation forKey:kCATransition];
|
||||
}
|
||||
|
||||
#pragma mark - NIMLoginManagerDelegate
|
||||
- (void)onAutoLoginFailed:(NSError *)error {
|
||||
// 如果非上次登录设备 autoLogin 会返回 417
|
||||
@@ -589,9 +624,23 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)xPAnchorCardViewClickAvatar:(NSString *)uid {
|
||||
if (uid.length) {
|
||||
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
|
||||
userInfoVC.uid = uid.integerValue;
|
||||
[self.selectedViewController.navigationController pushViewController:userInfoVC animated:YES];
|
||||
[self.anchorCardView removeFromSuperview];
|
||||
self.anchorCardView = nil;
|
||||
self.needShowAnchorCard = NO;
|
||||
} else {
|
||||
[self.anchorCardView removeFromSuperview];
|
||||
self.anchorCardView = nil;
|
||||
self.needShowAnchorCard = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
|
||||
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
|
||||
NSLog(@"swipe up");
|
||||
[UIView animateWithDuration:0.5 animations:^{
|
||||
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
||||
} completion:^(BOOL finished) {
|
||||
|
Reference in New Issue
Block a user