Commit 99f97c44 authored by zhangshuai's avatar zhangshuai

增加动画

parent 053f2fa1
......@@ -16,7 +16,7 @@
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LdK-dh-ill">
<rect key="frame" x="10" y="10" width="394" height="55"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="钻石" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oZ2-Ql-o18">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="可获" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oZ2-Ql-o18">
<rect key="frame" x="334" y="10" width="60" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="S2N-O7-A1J"/>
......
......@@ -24,6 +24,14 @@ NS_ASSUME_NONNULL_BEGIN
//添加右侧按钮
- (void)addRightItme:(UIImage * __nullable)image selecedImage:(UIImage * __nullable)sImage orText:(NSString * __nullable)text selectedText:(NSString * __nullable)sText;
- (void)rightBarButtonItemAction:(UIButton *)btn;
/// 缩放动画
/// @param toValue 默认为 1.2
/// @param fromValue 默认为 0.8
/// @param key 默认为 transform.scale
+(CABasicAnimation *)transformAnimationToValue:(NSValue *) toValue FromValue:(NSValue *)fromValue withKey:(NSString *)key;
@end
NS_ASSUME_NONNULL_END
......@@ -156,4 +156,22 @@
NSLog(@"rightButton click");
}
/// 缩放动画
/// @param toValue 默认为 1.2
/// @param fromValue 默认为 0.8
/// @param key 默认为 transform.scale
+(CABasicAnimation *)transformAnimationToValue:(NSValue *) toValue FromValue:(NSValue *)fromValue withKey:(NSString *)key;{
CABasicAnimation * animation = [[CABasicAnimation alloc]init];
animation.duration = 0.5;
animation.fromValue = @(0.8);
animation.toValue = @(1.2);
animation.byValue = @(3);
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses = YES;
animation.repeatCount = MAXFLOAT;
return animation;
}
@end
......@@ -239,8 +239,21 @@
if (self.coinsProcess >= 6) {
[self.treasureBox setImage:[UIImage imageNamed:@"OpenTreasureChest"] forState:UIControlStateNormal];
CABasicAnimation * animation = [[CABasicAnimation alloc]init];
animation.duration = 0.5;
animation.fromValue = @(0.8);
animation.toValue = @(1.2);
animation.byValue = @(3);
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses = YES;
animation.repeatCount = MAXFLOAT;
// transform.scale
[self.treasureBox.layer addAnimation:animation forKey:@"transform.scale"];
}else{
[self.treasureBox setImage:[UIImage imageNamed:@"TreasureChestClose"] forState:UIControlStateNormal];
[self.treasureBox.layer removeAnimationForKey:@"transform.scale"];
}
self.currentText.text = [NSString stringWithFormat:@"%ld",self.coinsProcess];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment