@@ -28,7 +28,23 @@
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView6 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView7 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView8 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy1 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy2 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy3 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy4 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy5 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy6 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy7 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userViewCopy8 ;
@ property ( nonatomic , strong ) NSMutableArray * userViews ;
@ property ( nonatomic , strong ) NSMutableArray * userViewCopys ;
@ property ( nonatomic , strong ) CADisplayLink * displayLink ;
@ property ( nonatomic , assign ) CGFloat currentRotation ;
@ property ( nonatomic , assign ) CGFloat rotationSpeed ;
@ end
@ implementation QXExpansionAppStoreView
@@ -117,34 +133,40 @@
// } ] ;
self . userView1 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ( self . centerBgView . width - ScaleWidth ( 56 ) ) / 2 , 0 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView1 . hidden = YES ;
[ self . centerBgView addSubview : self . userView1 ] ;
self . userView2 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView1 . right + ScaleWidth ( 54 ) , self . userView1 . top + ScaleWidth ( 45 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView2 . hidden = YES ;
[ self . centerBgView addSubview : self . userView2 ] ;
self . userView3 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( SCREEN_WIDTH - ScaleWidth ( 66 ) , ( self . centerBgView . height - ScaleWidth ( 71 ) ) / 2 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView3 . hidden = YES ;
[ self . centerBgView addSubview : self . userView3 ] ;
self . userView4 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView2 . left , self . userView3 . bottom + ScaleWidth ( 32 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView4 . hidden = YES ;
[ self . centerBgView addSubview : self . userView4 ] ;
self . userView5 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView1 . left , self . centerBgView . height - ScaleWidth ( 71 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView5 . hidden = YES ;
[ self . centerBgView addSubview : self . userView5 ] ;
self . userView7 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ScaleWidth ( 10 ) , self . userView3 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView7 . hidden = YES ;
[ self . centerBgView addSubview : self . userView7 ] ;
self . userView8 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ScaleWidth ( 48 ) , self . userView2 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView8 . hidden = YES ;
[ self . centerBgView addSubview : self . userView8 ] ;
self . userView6 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView8 . left , self . userView4 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
self . userView6 . hidden = YES ;
[ self . centerBgView addSubview : self . userView6 ] ;
[ self . userViews addObject : self . userView1 ] ;
[ self . userViews addObject : self . userView2 ] ;
[ self . userViews addObject : self . userView3 ] ;
@@ -153,15 +175,63 @@
[ self . userViews addObject : self . userView6 ] ;
[ self . userViews addObject : self . userView7 ] ;
[ self . userViews addObject : self . userView8 ] ;
self . userView1 . alpha = 0 ;
self . userView2 . alpha = 0 ;
self . userView3 . alpha = 0 ;
self . userView4 . alpha = 0 ;
self . userViewCopy1 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView1 . frame ] ;
self . userViewCopy1 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy1 ] ;
self . userView5 . alpha = 0 ;
self . userView6 . alpha = 0 ;
self . userView7 . alpha = 0 ;
self . userView8 . alpha = 0 ;
self . userViewCopy2 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView2 . frame ] ;
self . userViewCopy2 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy2 ] ;
self . userViewCopy3 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView3 . frame ] ;
self . userViewCopy3 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy3 ] ;
self . userViewCopy4 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView4 . frame ] ;
self . userViewCopy4 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy4 ] ;
self . userViewCopy5 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView5 . frame ] ;
self . userViewCopy5 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy5 ] ;
self . userViewCopy7 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView7 . frame ] ;
self . userViewCopy7 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy7 ] ;
self . userViewCopy8 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView8 . frame ] ;
self . userViewCopy8 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy8 ] ;
self . userViewCopy6 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : self . userView6 . frame ] ;
self . userViewCopy6 . hidden = YES ;
[ self . centerBgView addSubview : self . userViewCopy6 ] ;
[ self . userViewCopys addObject : self . userViewCopy1 ] ;
[ self . userViewCopys addObject : self . userViewCopy2 ] ;
[ self . userViewCopys addObject : self . userViewCopy3 ] ;
[ self . userViewCopys addObject : self . userViewCopy4 ] ;
[ self . userViewCopys addObject : self . userViewCopy5 ] ;
[ self . userViewCopys addObject : self . userViewCopy6 ] ;
[ self . userViewCopys addObject : self . userViewCopy7 ] ;
[ self . userViewCopys addObject : self . userViewCopy8 ] ;
self . userViewCopy1 . alpha = 0 ;
self . userViewCopy2 . alpha = 0 ;
self . userViewCopy3 . alpha = 0 ;
self . userViewCopy4 . alpha = 0 ;
self . userViewCopy5 . alpha = 0 ;
self . userViewCopy6 . alpha = 0 ;
self . userViewCopy7 . alpha = 0 ;
self . userViewCopy8 . alpha = 0 ;
MJWeakSelf
[ self . userView1 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
@@ -209,28 +279,75 @@
weakSelf . userBlock ( weakSelf . userView8 . model ) ;
}
} ] ;
[ self startAnimate ] ;
[ self . userView1 startSmoothFloatAnimation ] ;
[ self . userView2 startSmoothFloatAnimation ] ;
[ self . userView3 startSmoothFloatAnimation ] ;
[ self . userView4 startSmoothFloatAnimation ] ;
[ self . userView5 startSmoothFloatAnimation ] ;
[ self . userView6 startSmoothFloatAnimation ] ;
[ self . userView7 startSmoothFloatAnimation ] ;
[ self . userView8 startSmoothFloatAnimation ] ;
// [ self startAnimate ] ;
// [ self . userView1 startSmoothFloatAnimation ] ;
// [ self . userView2 startSmoothFloatAnimation ] ;
// [ self . userView3 startSmoothFloatAnimation ] ;
// [ self . userView4 startSmoothFloatAnimation ] ;
// [ self . userView5 startSmoothFloatAnimation ] ;
// [ self . userView6 startSmoothFloatAnimation ] ;
// [ self . userView7 startSmoothFloatAnimation ] ;
// [ self . userView8 startSmoothFloatAnimation ] ;
self . rotationSpeed = ( M_PI * 2 ) / ( 30.0 * 60.0 ) ; // 30 秒 一 圈
[ self startWheelRotation ] ;
}
- ( void ) startWheelRotation {
self . currentRotation = 0 ;
self . displayLink = [ CADisplayLink displayLinkWithTarget : self selector : @ selector ( updateWheelRotation ) ] ;
[ self . displayLink addToRunLoop : [ NSRunLoop mainRunLoop ] forMode : NSRunLoopCommonModes ] ;
}
- ( void ) updateWheelRotation {
// 更 新 旋 转 角 度
self . currentRotation + = self . rotationSpeed ;
if ( self . currentRotation >= M_PI * 2 ) {
self . currentRotation - = M_PI * 2 ;
}
// 方 案 1 : 使 用 CGAffineTransform ( 推 荐 )
[ self updateRotationWithCGAffineTransform ] ;
// 或 者 方 案 2 : 使 用 CATransform3D
// [ self updateRotationWithCATransform3D ] ;
// 更 新 调 试 信 息
// [ self updateDebugInfo ] ;
}
// 方 案 1 : 使 用 CGAffineTransform ( 推 荐 )
- ( void ) updateRotationWithCGAffineTransform {
// 应 用 摩 天 轮 旋 转
self . centerBgView . transform = CGAffineTransformMakeRotation ( self . currentRotation ) ;
// 关 键 修 复 : 头 像 反 向 旋 转 保 持 垂 直
// 注 意 : 这 里 使 用 identity 来 重 置 transform , 然 后 应 用 反 向 旋 转
for ( QXExpansionAppStoreSubView * avatarView in self . userViews ) {
// 重 置 transform 到 初 始 状 态 , 然 后 应 用 反 向 旋 转
avatarView . transform = CGAffineTransformIdentity ;
avatarView . transform = CGAffineTransformMakeRotation ( - self . currentRotation ) ;
}
for ( QXExpansionAppStoreSubView * avatarView in self . userViewCopys ) {
// 重 置 transform 到 初 始 状 态 , 然 后 应 用 反 向 旋 转
avatarView . transform = CGAffineTransformIdentity ;
avatarView . transform = CGAffineTransformMakeRotation ( - self . currentRotation ) ;
}
}
- ( void ) startAnimate {
CABasicAnimation * rotationAnimation = [ CABasicAnimation animationWithKeyPath : @ "transform.rotation.z" ] ;
// 旋 转 角 度
rotationAnimation . toValue = [ NSNumber numberWithFloat : M_PI ] ;
// 每 次 旋 转 的 时 间 ( 单 位 秒 )
rotationAnimation . duration = 15 ;
rotationAnimation . cumulative = YES ;
rotationAnimation . removedOnCompletion = NO ;
// 重 复 旋 转 的 次 数 , 如 果 你 想 要 无 数 次 , 那 么 设 置 成 MAXFLOAT
rotationAnimation . repeatCount = MAXFLOAT ;
[ self . centerBgView . layer addAnimation : rotationAnimation forKey : @ "rotationAnimation" ] ;
// CABasicAnimation * rotationAnimation = [ CABasicAnimation animationWithKeyPath : @ "transform.rotation.z" ] ;
// // 旋 转 角 度
// rotationAnimation . toValue = [ NSNumber numberWithFloat : M_PI ] ;
// // 每 次 旋 转 的 时 间 ( 单 位 秒 )
// rotationAnimation . duration = 15 ;
// rotationAnimation . cumulative = YES ;
// rotationAnimation . removedOnCompletion = NO ;
// // 重 复 旋 转 的 次 数 , 如 果 你 想 要 无 数 次 , 那 么 设 置 成 MAXFLOAT
// rotationAnimation . repeatCount = MAXFLOAT ;
// [ self . centerBgView . layer addAnimation : rotationAnimation forKey : @ "rotationAnimation" ] ;
}
@@ -246,37 +363,57 @@
self . fengcheImageView . alpha = 0 ;
self . fengcheImageView . hidden = NO ;
self . userViewCopy1 . hidden = NO ;
self . userViewCopy2 . hidden = NO ;
self . userViewCopy3 . hidden = NO ;
self . userViewCopy4 . hidden = NO ;
self . userViewCopy5 . hidden = NO ;
self . userViewCopy6 . hidden = NO ;
self . userViewCopy7 . hidden = NO ;
self . userViewCopy8 . hidden = NO ;
self . userView1 . hidden = YES ;
self . userView2 . hidden = YES ;
self . userView3 . hidden = YES ;
self . userView4 . hidden = YES ;
self . userView5 . hidden = YES ;
self . userView6 . hidden = YES ;
self . userView7 . hidden = YES ;
self . userView8 . hidden = YES ;
[ UIView animateWithDuration : 0.3 animations : ^ {
self . changeBtn . alpha = 0 ;
self . fengcheImageView . alpha = 1 ;
self . userView1 . centerX = self . bgImageView . centerX ;
self . userView1 . centerY = self . bgImageView . centerY ;
self . userView2 . centerX = self . bgImageView . centerX ;
self . userView2 . centerY = self . bgImageView . centerY ;
self . userView3 . centerX = self . bgImageView . centerX ;
self . userView3 . centerY = self . bgImageView . centerY ;
self . userView4 . centerX = self . bgImageView . centerX ;
self . userView4 . centerY = self . bgImageView . centerY ;
self . userView5 . centerX = self . bgImageView . centerX ;
self . userView5 . centerY = self . bgImageView . centerY ;
self . userView6 . centerX = self . bgImageView . centerX ;
self . userView6 . centerY = self . bgImageView . centerY ;
self . userView7 . centerX = self . bgImageView . centerX ;
self . userView7 . centerY = self . bgImageView . centerY ;
self . userView8 . centerX = self . bgImageView . centerX ;
self . userView8 . centerY = self . bgImageView . centerY ;
self . userView1 . alpha = 0 ;
self . userView2 . alpha = 0 ;
self . userView3 . alpha = 0 ;
self . userView4 . alpha = 0 ;
self . userView5 . alpha = 0 ;
self . userView6 . alpha = 0 ;
self . userView7 . alpha = 0 ;
self . userView8 . alpha = 0 ;
self . userViewCopy1 . centerX = self . bgImageView . centerX ;
self . userViewCopy1 . centerY = self . bgImageView . centerY ;
self . userViewCopy2 . centerX = self . bgImageView . centerX ;
self . userViewCopy2 . centerY = self . bgImageView . centerY ;
self . userViewCopy3 . centerX = self . bgImageView . centerX ;
self . userViewCopy3 . centerY = self . bgImageView . centerY ;
self . userViewCopy4 . centerX = self . bgImageView . centerX ;
self . userViewCopy4 . centerY = self . bgImageView . centerY ;
self . userViewCopy5 . centerX = self . bgImageView . centerX ;
self . userViewCopy5 . centerY = self . bgImageView . centerY ;
self . userViewCopy6 . centerX = self . bgImageView . centerX ;
self . userViewCopy6 . centerY = self . bgImageView . centerY ;
self . userViewCopy7 . centerX = self . bgImageView . centerX ;
self . userViewCopy7 . centerY = self . bgImageView . centerY ;
self . userViewCopy8 . centerX = self . bgImageView . centerX ;
self . userViewCopy8 . centerY = self . bgImageView . centerY ;
self . userViewCopy1 . alpha = 0 ;
self . userViewCopy2 . alpha = 0 ;
self . userViewCopy3 . alpha = 0 ;
self . userViewCopy4 . alpha = 0 ;
self . userViewCopy5 . alpha = 0 ;
self . userViewCopy6 . alpha = 0 ;
self . userViewCopy7 . alpha = 0 ;
self . userViewCopy8 . alpha = 0 ;
} completion : ^ ( BOOL finished ) {
self . changeBtn . hidden = YES ;
@@ -303,32 +440,48 @@
self . changeBtn . alpha = 0 ;
self . changeBtn . hidden = NO ;
self . fengcheImageView . hidden = YES ;
dispatch_async ( dispatch_get _main _queue ( ) , ^ {
[ self configData ] ;
} ) ;
[ self configData ] ;
[ UIView animateWithDuration : 0.3 animations : ^ {
self . changeBtn . alpha = 1 ;
self . userViewCopy1 . frame = self . userView1 . frame ;
self . userViewCopy2 . frame = self . userView2 . frame ;
self . userViewCopy3 . frame = self . userView3 . frame ;
self . userViewCopy4 . frame = self . userView4 . frame ;
self . userViewCopy5 . frame = self . userView5 . frame ;
self . userViewCopy6 . frame = self . userView6 . frame ;
self . userViewCopy7 . frame = self . userView7 . frame ;
self . userViewCopy8 . frame = self . userView8 . frame ;
self . userViewCopy1 . alpha = 1 ;
self . userViewCopy2 . alpha = 1 ;
self . userViewCopy3 . alpha = 1 ;
self . userViewCopy4 . alpha = 1 ;
self . userViewCopy5 . alpha = 1 ;
self . userViewCopy6 . alpha = 1 ;
self . userViewCopy7 . alpha = 1 ;
self . userViewCopy8 . alpha = 1 ;
self . userView1 . frame = CGRectMake ( ( self . centerBgView . width - ScaleWidth ( 56 ) ) / 2 , 0 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView2 . frame = CGRectMake ( self . userView1 . right + ScaleWidth ( 54 ) , self . userView1 . top + ScaleWidth ( 45 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView3 . frame = CGRectMake ( SCREEN_WIDTH - ScaleWidth ( 66 ) , ( self . centerBgView . height - ScaleWidth ( 71 ) ) / 2 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView4 . frame = CGRectMake ( self . userView2 . left , self . userView3 . bottom + ScaleWidth ( 32 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView5 . frame = CGRectMake ( self . userView1 . left , self . centerBgView . height - ScaleWidth ( 71 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView7 . frame = CGRectMake ( ScaleWidth ( 10 ) , self . userView3 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView8 . frame = CGRectMake ( ScaleWidth ( 48 ) , self . userView2 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView6 . frame = CGRectMake ( self . userView8 . left , self . userView4 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView1 . alpha = 1 ;
self . userView2 . alpha = 1 ;
self . userView3 . alpha = 1 ;
self . userView4 . alpha = 1 ;
self . userView5 . alpha = 1 ;
self . userView6 . alpha = 1 ;
self . userView7 . alpha = 1 ;
self . userView8 . alpha = 1 ;
} completion : ^ ( BOOL finished ) {
self . userViewCopy1 . hidden = YES ;
self . userViewCopy2 . hidden = YES ;
self . userViewCopy3 . hidden = YES ;
self . userViewCopy4 . hidden = YES ;
self . userViewCopy5 . hidden = YES ;
self . userViewCopy6 . hidden = YES ;
self . userViewCopy7 . hidden = YES ;
self . userViewCopy8 . hidden = YES ;
self . userView1 . hidden = NO ;
self . userView2 . hidden = NO ;
self . userView3 . hidden = NO ;
self . userView4 . hidden = NO ;
self . userView5 . hidden = NO ;
self . userView6 . hidden = NO ;
self . userView7 . hidden = NO ;
self . userView8 . hidden = NO ;
} ] ;
}
- ( void ) setUsers : ( NSArray * ) users {
@@ -349,7 +502,9 @@
for ( int i = 0 ; i < self . randomArray . count ; i + + ) {
QXUserHomeModel * md = self . randomArray [ i ] ;
QXExpansionAppStoreSubView * v = self . userViews [ i ] ;
QXExpansionAppStoreSubView * cv = self . userViewCopys [ i ] ;
v . model = md ;
cv . model = [ md copyModel ] ;
}
}
@@ -383,6 +538,12 @@
}
return _userViews ;
}
- ( NSMutableArray * ) userViewCopys {
if ( ! _userViewCopys ) {
_userViewCopys = [ NSMutableArray array ] ;
}
return _userViewCopys ;
}
@ end
@@ -405,6 +566,7 @@
self . nameBgView . hidden = NO ;
}
- ( void ) initSubviews {
self . transform = CGAffineTransformRotate ( self . transform , M_PI ) ;
self . headerImageView = [ [ UIImageView alloc ] init ] ;
self . headerImageView . contentMode = UIViewContentModeScaleAspectFill ;
[ self . headerImageView addRoundedCornersWithRadius : self . width / 2 ] ;
@@ -444,7 +606,9 @@
make . height . width . mas_offset ( 16 ) ;
} ] ;
}
- ( void ) startSmoothFloatAnimation {
// [ self animateFloatUp ] ;
CABasicAnimation * rotationAnimation = [ CABasicAnimation animationWithKeyPath : @ "transform.rotation.z" ] ;
// 旋 转 角 度
@@ -456,6 +620,18 @@
// 重 复 旋 转 的 次 数 , 如 果 你 想 要 无 数 次 , 那 么 设 置 成 MAXFLOAT
rotationAnimation . repeatCount = MAXFLOAT ;
[ self . layer addAnimation : rotationAnimation forKey : @ "rotationAnimation" ] ;
// [ UIView animateWithDuration : 15.0
// delay : 0.0
// options : UIViewAnimationOptionCurveLinear | UIViewKeyframeAnimationOptionAllowUserInteraction
// animations : ^ {
// self . transform = CGAffineTransformRotate ( self . transform , 2 * M_PI ) ;
// }
// completion : ^ ( BOOL finished ) {
// if ( finished ) {
// // 递 归 调 用 实 现 无 限 旋 转
// [ self startSmoothFloatAnimation ] ;
// }
// } ] ;
}