iOS label闪动提示

写一个图层的类别

#import


@interface CALayer (Anim)

/*

 *  摇动

*/

-(void)shake;


@end

#import "CALayer+Anim.h"


@implementation CALayer (Anim)


-(void)shake{

    

    CAKeyframeAnimation *kfa = [CAKeyframeAnimationanimationWithKeyPath:@"transform.translation.x"];

    

    CGFloat s =16;

    

    kfa.values =@[@(-s),@(0),@(s),@(0),@(-s),@(0),@(s),@(0)];

    

    //时长

    kfa.duration =.1f;

    

    //重复

    kfa.repeatCount =2;

    

    //移除

    kfa.removedOnCompletion =YES;

    

    [selfaddAnimation:kfa forKey:@"shake"];

}


@end



你可能感兴趣的:(移动开发,iOS)