美文网首页iOS 组件
IOS 组件之 AitiveTouch

IOS 组件之 AitiveTouch

作者: wnido | 来源:发表于2017-08-24 11:45 被阅读15次

    避免重复造轮子

    功能和效果

    • 功能
      实现类似苹果自带 AitiveTouch 功能

    • 效果
      心塞了,不能上传视频...

    image.png

    应用到的技术

    • 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];
    

    后续

    若有需求,会针对性做出扩展


    代码链接

    https://github.com/Supecomer/AitiveTouch

    相关文章

      网友评论

        本文标题:IOS 组件之 AitiveTouch

        本文链接:https://www.haomeiwen.com/subject/sxosdxtx.html