避免重复造轮子
功能和效果
-
功能
实现类似苹果自带 AitiveTouch 功能 -
效果
心塞了,不能上传视频...
应用到的技术
- CADisplayLink
- GestureRecognizer
- 库封装
接口
typedef void(^voidBlock)(void);
@interface CIAitiveTouchView : UIView
/**
animation rate,default 1.0
*/
@property (nonatomic,assign) float rate;
/**
alpha when activity,default 1.0
*/
@property (nonatomic,assign) float activityAlpha;
/**
alpha when unactivity,default 0.3
*/
@property (nonatomic,assign) float unactivityAlpha;
/**
show time ,defulat 0.2s
*/
@property (nonatomic,assign) float showTime;
/**
hiddenTime time ,defulat 0.2s
*/
@property (nonatomic,assign) float hiddenTime;
/**
background image,defualt is nill
*/
@property (nonatomic,strong) UIImage *backgroundImage;
/**
view is can touch ,defualt is yes
*/
@property (nonatomic,assign) BOOL isCanTouch;
- (void)setTapGestureFuction:(voidBlock)block;
+ (CIAitiveTouchView *)getInstance;
- (void)show;
- (void)hidden;
- (void)remove;
@end
接入代码
CIAitiveTouchView *touchView = [[CIAitiveTouchView alloc] init];
touchView.backgroundColor = [UIColor orangeColor];
touchView.frame = CGRectMake(0, 0, 100, 100);
touchView.backgroundImage = [UIImage imageNamed:@"background"];
touchView.layer.cornerRadius = 50;
touchView.unactivityAlpha = 0.5;
[self.view addSubview:touchView];
后续
若有需求,会针对性做出扩展
网友评论