最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS實(shí)現(xiàn)圖片抖動效果

 更新時間:2020年02月22日 07:18:06   作者:LayneCheung  
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)圖片抖動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)圖片抖動效果的具體代碼,供大家參考,具體內(nèi)容如下

效果圖:

核心代碼:

//
// ViewController.m
// 圖標(biāo)抖動
//
// Created by llkj on 2017/8/29.
// Copyright © 2017年 LayneCheung. All rights reserved.
//

#import "ViewController.h"

#define angle2Rad(angle) ((angle) / 180.0 *M_PI)

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imageV;
@end

@implementation ViewController

- (void)viewDidLoad {
 [super viewDidLoad];

 self.imageV.userInteractionEnabled = YES;
 //添加長按手勢
 UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];

 [self.imageV addGestureRecognizer:longPress];
}

- (void)longPress:(UILongPressGestureRecognizer *)longPress{

 //創(chuàng)建動畫對象
 CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];

 anim.keyPath = @"transform.rotation";
 anim.values = @[@(angle2Rad(-5)),@(angle2Rad(5))];
 anim.repeatCount = MAXFLOAT;
// anim.duration = 1;
 anim.autoreverses = YES;


 [self.imageV.layer addAnimation:anim forKey:nil];

}

- (void)didReceiveMemoryWarning {
 [super didReceiveMemoryWarning];
 // Dispose of any resources that can be recreated.
}


@end

小編再給大家補(bǔ)充一段iOS UIView視圖抖動效果的實(shí)現(xiàn)代碼:

/**
 * 抖動效果
 *
 * @param view 要抖動的view
 */
- (void)shakeAnimationForView:(UIView *) view {
 CALayer *viewLayer = view.layer;
 CGPoint position = viewLayer.position;
 CGPoint x = CGPointMake(position.x + 1, position.y);
 CGPoint y = CGPointMake(position.x - 1, position.y);
 CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
 [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
 [animation setFromValue:[NSValue valueWithCGPoint:x]];
 [animation setToValue:[NSValue valueWithCGPoint:y]];
 [animation setAutoreverses:YES];
 [animation setDuration:.06];
 [animation setRepeatCount:3];
 [viewLayer addAnimation:animation forKey:nil];
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

通许县| 独山县| 枣庄市| 广宁县| 周至县| 龙口市| 建瓯市| 广河县| 安多县| 雷山县| 乐业县| 南雄市| 即墨市| 海南省| 饶平县| 安多县| 新源县| 城市| 怀仁县| 马鞍山市| 双桥区| 营山县| 色达县| 凤山县| 渑池县| 阳山县| 南漳县| 景德镇市| 罗田县| 柘荣县| 普兰店市| 扎鲁特旗| 江安县| 南汇区| 凤庆县| 咸丰县| 南宫市| 江北区| 若羌县| 鹰潭市| 怀安县|