@@ -8,8 +8,14 @@
# import "QXExpansionAppStoreView.h"
# import "CKShimmerLabel.h"
@ interface QXExpansionAppStoreView ( ) < CAAnimationDelegate >
@ property ( nonatomic , strong ) CKShimmerLabel * titleLabel ;
@ property ( nonatomic , strong ) UIImageView * topCenterImageView ;
@ property ( nonatomic , strong ) UIImageView * moonImageView ;
@ property ( nonatomic , strong ) UIImageView * bottomImageView ;
@ property ( nonatomic , strong ) UIImageView * legImageView ;
@ property ( nonatomic , strong ) UIView * centerBgView ;
@ property ( nonatomic , strong ) UIImageView * bgImageView ;
@ property ( nonatomic , strong ) UIImageView * fengcheImageView ;
@ property ( nonatomic , strong ) UIButton * changeBtn ;
@ property ( nonatomic , strong ) NSMutableArray * randomArray ;
@@ -18,6 +24,10 @@
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView2 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView3 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView4 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView5 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView6 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView7 ;
@ property ( nonatomic , strong ) QXExpansionAppStoreSubView * userView8 ;
@ property ( nonatomic , strong ) NSMutableArray * userViews ;
@ end
@@ -44,54 +54,61 @@
}
- ( void ) initSubviews {
self . topCenterImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "exbpansion_word" ] ] ;
self . topCenterImageView . frame = CGRectMake ( ( SCREEN_WIDTH - ScaleWidth ( 275 ) ) / 2 , 17 , ScaleWidth ( 275 ) , ScaleWidth ( 40 ) ) ;
self . topCenterImageView . contentMode = UIViewContentModeScaleToFill ;
[ self addSubview : self . topCenterImageView ] ;
self . bg ImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "expansion_bg " ] ] ;
self . bg ImageView. fram e = CGRectMake ( ( self . width -375 ) / 2 , ( self . height -375 ) / 2 -20 , 375 , 375 ) ;
[ self addSubview : self . bg ImageView] ;
self . moon ImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "exb pansion_moon " ] ] ;
self . moon ImageView. contentMod e = UIViewContentModeScaleToFill ;
self . moonImageView . frame = CGRectMake ( self . topCenter ImageView. right , 5 , ScaleWidth ( 44 ) , ScaleWidth ( 52 ) ) ;
[ self addSubview : self . moonImageView ] ;
self . bottomImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "exbpansion_bottom_bg" ] ] ;
self . bottomImageView . frame = CGRectMake ( 0 , self . height - ScaleWidth ( 180 ) , SCREEN_WIDTH , ScaleWidth ( 180 ) ) ;
self . bottomImageView . contentMode = UIViewContentModeScaleToFill ;
[ self addSubview : self . bottomImageView ] ;
self . legImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "exbpansion_bottom_leg" ] ] ;
self . legImageView . contentMode = UIViewContentModeScaleToFill ;
self . legImageView . frame = CGRectMake ( ( SCREEN_WIDTH - ScaleWidth ( 175 ) ) / 2 , self . bottomImageView . top - ScaleWidth ( 240 -56 ) , ScaleWidth ( 175 ) , ScaleWidth ( 240 ) ) ;
[ self insertSubview : self . legImageView belowSubview : self . bottomImageView ] ;
self . centerBgView = [ [ UIView alloc ] initWithFrame : CGRectMake ( 0 , self . legImageView . top - SCREEN_WIDTH / 2 , SCREEN_WIDTH , SCREEN_WIDTH ) ] ;
[ self addSubview : self . centerBgView ] ;
self . bgImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "exbpansion_center_bg" ] ] ;
self . bgImageView . frame = CGRectMake ( ( SCREEN_WIDTH - ScaleWidth ( 300 ) ) / 2 , ( SCREEN_WIDTH - ScaleWidth ( 300 ) ) / 2 , ScaleWidth ( 300 ) , ScaleWidth ( 300 ) ) ;
[ self . centerBgView addSubview : self . bgImageView ] ;
// [ self . bgImageView mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . height . width . mas_equalTo ( 375 ) ;
// make . centerX . centerY . equalTo ( self ) ;
// } ] ;
self . titleLabel = [ [ CKShimmerLabel alloc ] init ] ;
self . titleLabel . shimmerWidth = 20 ;
self . titleLabel . shimmerRadius = 20 ;
self . titleLabel . shimmerColor = QXConfig . themeColor ;
self . titleLabel . shimmerType = ST_LeftToRight ;
self . titleLabel . repeat = YES ;
self . titleLabel . textColor = RGB16 ( 0 x333333 ) ;
self . titleLabel . font = [ UIFont fontWithName : @ "YouSheBiaoTiHei" size : 30 ] ;
self . titleLabel . text = @ "风车转转转,找寻新玩伴" ;
self . titleLabel . top = 80 ;
[ self . titleLabel . contentLabel sizeToFit ] ;
self . titleLabel . width = self . titleLabel . contentLabel . width ;
self . titleLabel . centerX = self . centerX ;
[ self . titleLabel startShimmer ] ;
[ self addSubview : self . titleLabel ] ;
self . fengcheImageView = [ [ UIImageView alloc ] initWithImage : [ UIImage imageNamed : @ "fengche" ] ] ;
self . fengcheImageView . hidden = YES ;
self . fengcheImageView . frame = CGRectMake ( ( self . width -70 ) / 2 , ( self . height -7 0) / 2 -20 , 70 , 70 ) ;
[ self . fengcheImageView addRoundedCornersWithRadius : 35 ] ;
self . fengcheImageView . frame = CGRectMake ( ( self . centerBgView . width - ScaleWidth ( 60 ) ) / 2 , ( self . centerBgView . top - ScaleWidth ( 6 0) ) / 2 , ScaleWidth ( 60 ) , ScaleWidth ( 60 ) ) ;
[ self . fengcheImageView addRoundedCornersWithRadius : ScaleWidth ( 30 ) ] ;
self . fengcheImageView . layer . borderWidth = 5 ;
self . fengcheImageView . layer . borderColor = UIColor . whiteColor . CGColor ;
self . fengcheImageView . centerX = self . centerBgView . centerX ;
self . fengcheImageView . centerY = self . centerBgView . centerY ;
[ self addSubview : self . fengcheImageView ] ;
// [ self . fengcheImageView mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . centerY . centerX . equalTo ( self . bgImageView ) ;
// make . height . width . mas_offset ( 70 ) ;
// } ] ;
self . changeBtn = [ [ UIButton alloc ] init ] ;
self . changeBtn . frame = self . fengcheImageView . frame ;
self . changeBtn . backgroundColor = QXConfig . themeColor ;
[ self . changeBtn addRoundedCornersWithRadius : 35 ] ;
[ self . changeBtn setTitle : @ "换一批 " forState : ( UIControlStateNormal ) ] ;
[ self . changeBtn addRoundedCornersWithRadius : ScaleWidth ( 30 ) ] ;
[ self . changeBtn setTitle : @ "换" forState : ( UIControlStateNormal ) ] ;
self . changeBtn . layer . borderWidth = 5 ;
self . changeBtn . layer . borderColor = UIColor . whiteColor . CGColor ;
self . changeBtn . titleLabel . font = [ UIFont systemFontOfSize : 15 ] ;
[ self . changeBtn setTitleColor : RGB16 ( 0 x333333 ) forState : ( UIControlStateNormal ) ] ;
[ self . changeBtn setTitleColor : RGB16 ( 0 xffffff ) forState : ( UIControlStateNormal ) ] ;
[ self . changeBtn addTarget : self action : @ selector ( changeAction : ) forControlEvents : ( UIControlEventTouchUpInside ) ] ;
[ self addSubview : self . changeBtn ] ;
// [ self . changeBtn mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
@@ -99,45 +116,52 @@
// make . height . width . mas_offset ( 70 ) ;
// } ] ;
self . userView1 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . bgImage View. left + 40 , self . bgImageView . top + 28 , 100 , 100 ) ] ;
[ self addSubview : self . userView1 ] ;
// [ self . userView1 mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . left . equalTo ( self . bgImageView ) . offset ( 40 ) ;
// make . top . equalTo ( self . bgImageView ) . offset ( 32 ) ;
// make . width . mas_equalTo ( 100 ) ;
// make . height . mas_equalTo ( 100 ) ;
// } ] ;
self . userView1 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ( self . centerBg View. width - ScaleWidth ( 56 ) ) / 2 , 0 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView1 ] ;
self . userView2 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . bgImage View. right -40 -100 , self . bgImage View. top + 28 , 100 , 100 ) ] ;
[ self addSubview : self . userView2 ] ;
// [ self . userView2 mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . right . equalTo ( self . bgImageView ) . offset ( -40 ) ;
// mak e. top . equalTo ( self . bgImage View) . offset ( 32 ) ;
// make . width . mas_equalTo ( 100 ) ;
// make . height . mas_equalTo ( 100 ) ;
// } ] ;
self . userView2 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . user View1 . right + ScaleWidth ( 54 ) , self . user View1 . top + ScaleWidth ( 45 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView2 ] ;
self . userView3 = [ [ QXExpansionAppStoreSubView alloc ] initWithFram e: CGRectMake ( SCREEN_WIDTH - ScaleWidth ( 66 ) , ( self . centerBg View. height - ScaleWidth ( 71 ) ) / 2 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView3 ] ;
self . userView4 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView2 . left , self . userView3 . bottom + ScaleWidth ( 32 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView4 ] ;
self . userView5 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView1 . left , self . centerBgView . height - ScaleWidth ( 71 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView5 ] ;
self . userView7 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ScaleWidth ( 10 ) , self . userView3 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView7 ] ;
self . userView8 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( ScaleWidth ( 48 ) , self . userView2 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView8 ] ;
self . userView6 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . userView8 . left , self . userView4 . top , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ] ;
[ self . centerBgView addSubview : self . userView6 ] ;
self . userView3 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . bgImageView . left + 40 , self . bgImageView . bottom -55 -100 , 100 , 100 ) ] ;
[ self addSubview : self . userView3 ] ;
// [ self . userView3 mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . left . equalTo ( self . bgImageView ) . offset ( 40 ) ;
// make . bottom . equalTo ( self . bgImageView ) . offset ( -55 ) ;
// make . width . mas_equalTo ( 100 ) ;
// make . height . mas_equalTo ( 100 ) ;
// } ] ;
self . userView4 = [ [ QXExpansionAppStoreSubView alloc ] initWithFrame : CGRectMake ( self . bgImageView . right -40 -100 , self . bgImageView . bottom -55 -100 , 100 , 100 ) ] ;
[ self addSubview : self . userView4 ] ;
// [ self . userView4 mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
// make . right . equalTo ( self . bgImageView ) . offset ( -40 ) ;
// make . bottom . equalTo ( self . bgImageView ) . offset ( -55 ) ;
// make . width . mas_equalTo ( 100 ) ;
// make . height . mas_equalTo ( 100 ) ;
// } ] ;
[ self . userViews addObject : self . userView1 ] ;
[ self . userViews addObject : self . userView2 ] ;
[ self . userViews addObject : self . userView3 ] ;
[ self . userViews addObject : self . userView4 ] ;
[ self . userViews addObject : self . userView5 ] ;
[ 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 . userView5 . alpha = 0 ;
self . userView6 . alpha = 0 ;
self . userView7 . alpha = 0 ;
self . userView8 . alpha = 0 ;
MJWeakSelf
[ self . userView1 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
@@ -162,13 +186,63 @@
weakSelf . userBlock ( weakSelf . userView4 . model ) ;
}
} ] ;
[ self . userView5 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
weakSelf . userBlock ( weakSelf . userView5 . model ) ;
}
} ] ;
[ self . userView6 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
weakSelf . userBlock ( weakSelf . userView6 . model ) ;
}
} ] ;
[ self . userView7 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
weakSelf . userBlock ( weakSelf . userView7 . model ) ;
}
} ] ;
[ self . userView8 addTapBlock : ^ ( id _Nonnull obj ) {
if ( weakSelf . userBlock ) {
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 ] ;
}
- ( 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" ] ;
}
- ( void ) changeAction : ( UIButton * ) sender {
[ self . userView1 stopFloatAnimation ] ;
[ self . userView2 stopFloatAnimation ] ;
[ self . userView3 stopFloatAnimation ] ;
[ self . userView4 stopFloatAnimation ] ;
// [ self . userView1 stopFloatAnimation ] ;
// [ self . userView2 stopFloatAnimation ] ;
// [ self . userView3 stopFloatAnimation ] ;
// [ self . userView4 stopFloatAnimation ] ;
// [ self . userView5 stopFloatAnimation ] ;
// [ self . userView6 stopFloatAnimation ] ;
// [ self . userView7 stopFloatAnimation ] ;
// [ self . userView8 stopFloatAnimation ] ;
self . fengcheImageView . alpha = 0 ;
self . fengcheImageView . hidden = NO ;
@@ -185,13 +259,24 @@
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 ;
} completion : ^ ( BOOL finished ) {
self . changeBtn . hidden = YES ;
@@ -218,24 +303,32 @@
self . changeBtn . alpha = 0 ;
self . changeBtn . hidden = NO ;
self . fengcheImageView . hidden = YES ;
[ self configData ] ;
dispatch_async ( dispatch_get _main _queue ( ) , ^ {
[ self configData ] ;
} ) ;
[ UIView animateWithDuration : 0.3 animations : ^ {
self . changeBtn . alpha = 1 ;
self . userView1 . frame = CGRectMake ( self . bgImageView . left + 40 , self . bgImageView . top + 28 , 100 , 100 ) ;
self . userView2 . frame = CGRectMake ( self . bgImage View. right -40 -100 , self . bgImageView . top + 28 , 100 , 100 ) ;
self . userView3 . frame = CGRectMake ( self . bgImage View. left + 40 , self . bgImage View. bottom -55 -100 , 100 , 100 ) ;
self . userView4 . frame = CGRectMake ( self . bgImageView . right -40 -100 , self . bgImage View. bottom -55 -100 , 100 , 100 ) ;
self . userView1 . frame = CGRectMake ( ( self . centerBg View. width - ScaleWidth ( 56 ) ) / 2 , 0 , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView2 . frame = CGRectMake ( self . user View1 . right + ScaleWidth ( 54 ) , self . user View1 . top + ScaleWidth ( 45 ) , ScaleWidth ( 56 ) , ScaleWidth ( 71 ) ) ;
self . userView3 . frame = CGRectMake ( SCREEN_WIDTH - ScaleWidth ( 66 ) , ( self . centerBg View. 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 . userView1 startSmoothFloatAnimation ] ;
[ self . userView2 startSmoothFloatAnimation ] ;
[ self . userView3 startSmoothFloatAnimation ] ;
[ self . userView4 startSmoothFloatAnimation ] ;
} ] ;
}
- ( void ) setUsers : ( NSArray * ) users {
@@ -245,7 +338,7 @@
- ( void ) configData {
[ self . randomArray removeAllObjects ] ;
if ( _users . count <= 4 ) {
if ( _users . count <= 8 ) {
[ self . randomArray addObjectsFromArray : self . users ] ;
} else {
NSArray * rArr = [ self optimizedRandomFourNumbers ] ;
@@ -267,8 +360,8 @@
[ allNumbers addObject : @ ( i ) ] ;
}
NSMutableArray * result = [ NSMutableArray arrayWithCapacity : 4 ] ;
for ( int i = 0 ; i < 4 ; i + + ) {
NSMutableArray * result = [ NSMutableArray arrayWithCapacity : 8 ] ;
for ( int i = 0 ; i < 8 ; i + + ) {
int remainingCount = ( int ) allNumbers . count ;
int randomIndex = arc4random_uniform ( remainingCount ) ;
[ result addObject : allNumbers [ randomIndex ] ] ;
@@ -309,27 +402,39 @@
self . nameLabel . text = model . nickname ;
UIImage * sexImage = [ UIImage imageNamed : model . sex . intValue = = 1 ? @ "user_sex_boy" : @ "user_sex_girl" ] ;
self . sexImageView . image = sexImage ;
self . nameBgView . hidden = NO ;
}
- ( void ) initSubviews {
self . headerImageView = [ [ UIImageView alloc ] init ] ;
self . headerImageView . contentMode = UIViewContentModeScaleAspectFill ;
[ self . headerImageView addRoundedCornersWithRadius : 35 ] ;
// self . headerImageView . backgroundColor = [ UIColor brownColor ] ;;
[ self . headerImageView addRoundedCornersWithRadius : self . width / 2 ] ;
[ self addSubview : self . headerImageView ] ;
[ self . headerImageView mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
make . centerY . centerX. equalTo ( self ) ;
make . height . width . mas_offset ( 70 ) ;
make . centerX . equalTo ( self ) ;
make . top . equalTo ( self ) ;
make . height . width . mas_offset ( self . width ) ;
} ] ;
self . nameLabel = [ [ UILabel alloc ] init ] ;
self . nameLabel . textColor = RGB16 ( 0 x333333 ) ;
self . nameLabel . font = [ UIFont systemFontOfSize : 14 ] ;
// self . nameLabel . text = @ "张三" ;
self . nameLabel . textColor = RGB16 ( 0 xe5e5e5 ) ;
self . nameLabel . font = [ UIFont systemFontOfSize : 9 ] ;
[ self addSubview : self . nameLabel ] ;
[ self . nameLabel mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
make . top . equalTo ( self . headerImageView . mas_bottom ) . offset ( 8 ) ;
make . top . equalTo ( self . headerImageView . mas_bottom ) . offset ( 2 ) ;
make . centerX . equalTo ( self ) ;
make . height . mas_equalTo ( 20 ) ;
make . height . mas_equalTo ( ScaleWidth ( 15 ) ) ;
} ] ;
self . nameBgView = [ [ UIView alloc ] init ] ;
self . nameBgView . hidden = YES ;
self . nameBgView . backgroundColor = RGB16A ( 0 x000000 , 0.58 ) ;
[ self . nameBgView addRoundedCornersWithRadius : ScaleWidth ( 15 ) / 2 ] ;
[ self insertSubview : self . nameBgView belowSubview : self . nameLabel ] ;
[ self . nameBgView mas_makeConstraints : ^ ( MASConstraintMaker * make ) {
make . top . bottom . equalTo ( self . nameLabel ) ;
make . left . mas_equalTo ( -8 ) ;
make . right . mas_equalTo ( 8 ) ;
} ] ;
self . sexImageView = [ [ UIImageView alloc ] init ] ;
@@ -340,37 +445,20 @@
} ] ;
}
- ( void ) startSmoothFloatAnimation {
[ self animateFloatUp ] ;
// [ self animateFloatUp ] ;
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 . layer addAnimation : rotationAnimation forKey : @ "rotationAnimation" ] ;
}
- ( void ) animateFloatUp {
CGFloat floatDistance = 10.0 f ;
CGFloat duration = 2.0 f ;
[ UIView animateWithDuration : duration
delay : 0
options : UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
animations : ^ {
self . transform = CGAffineTransformMakeTranslation ( 0 , - floatDistance ) ;
}
completion : ^ ( BOOL finished ) {
[ self animateFloatDown ] ;
} ] ;
}
- ( void ) animateFloatDown {
CGFloat duration = 2.0 f ;
[ UIView animateWithDuration : duration
delay : 0
options : UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
animations : ^ {
self . transform = CGAffineTransformIdentity ;
}
completion : ^ ( BOOL finished ) {
[ self animateFloatUp ] ;
} ] ;
}
- ( void ) stopFloatAnimation {
[ self . layer removeAllAnimations ] ;