ui基础--放大缩小动画

首先我们用pod安装2个三方库:

use_frameworks!

target 'Love--动画' do
pod 'pop', '~> 1.0.9'
pod 'POP+MCAnimate', '~> 2.0'

end

实现代码:

#import "RootViewController.h"


@interface RootViewController ()
@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) dispatch_source_t timer;

@end

@implementation RootViewController

- (void)viewWillAppear:(BOOL)animated
{
    
    [self setupScoreAnimation];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"臭美";
    
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 300, 100, 100)];
    
    UIImage *image = [UIImage imageNamed:@"10"];
    
    self.myImageView.layer.cornerRadius = 50;
    self.myImageView.layer.masksToBounds = YES;
    
    self.myImageView.image = image;
    
    [self.view addSubview:_myImageView];
    
}

- (void)setupScoreAnimation
{
    dispatch_queue_t queue = dispatch_get_main_queue();
    
    self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
    dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
    uint64_t interval = (uint64_t)(1.0 * NSEC_PER_SEC);
    dispatch_source_set_timer(self.timer, start, interval, 0);
    dispatch_source_set_event_handler(self.timer, ^{
        
        [self animationStar];
    });
    
    dispatch_resume(self.timer);
}

- (void)animationStar
{
    [NSObject pop_animate:^{
        
        self.myImageView.pop_spring.pop_scaleXY = CGPointMake(1.5, 1.5);
        self.myImageView.pop_springBounciness = 20;
        self.myImageView.pop_springSpeed = 20;
    } completion:^(BOOL finished) {
        
        self.myImageView.pop_spring.pop_scaleXY = CGPointMake(1, 1);
        self.myImageView.pop_springBounciness = 20;
        self.myImageView.pop_springSpeed = 20;
    }];
}



@end

自己可以试试哈...

记得要将timer至nil啊.

- (void)viewDidDisappear:(BOOL)animated
{
    dispatch_cancel(self.timer);
    self.timer = nil;
}

完成...

转载于:https://www.cnblogs.com/LzwBlog/p/5730323.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现vue element-ui中的dialog边框放大缩小,可以使用CSS的transform属性和transition属性来达到效果。具体实现步骤如下: 1. 首先,在dialog组件中添加一个div元素作为边框,设置其样式为绝对定位、宽高100%、边框的宽度和颜色等。 2. 然后,使用CSS的transform属性和transition属性来实现放大缩小效果。将div元素的transform属性设置为scale(1)(原始大小),并设置transition属性为all 0.3s ease-in-out(缩放动画时间和缓动效果)。 3. 最后,在需要放大缩小边框的时候,使用Vue的$refs来获取到该div元素,并将其transform属性设置为scale(1.2)(放大)或scale(1)(缩小)即可。 下面是一个简单的示例代码: ``` <template> <el-dialog :visible.sync="dialogVisible" :title="title" :width="width" :before-close="handleClose"> <div class="dialog-border" ref="border"></div> <div>{{ content }}</div> </el-dialog> </template> <script> export default { data() { return { dialogVisible: false, title: 'Dialog标题', width: '50%', content: 'Dialog内容' } }, methods: { handleClose(done) { this.$refs.border.style.transform = 'scale(1)'; setTimeout(() => { done(); }, 300); }, handleClick() { this.dialogVisible = true; this.$refs.border.style.transform = 'scale(1.2)'; } } } </script> <style scoped> .dialog-border { position: absolute; width: 100%; height: 100%; border: 2px solid #409EFF; top: 0; left: 0; transform: scale(1); transition: all 0.3s ease-in-out; } </style> ``` 以上代码仅供参考,具体实现方式可以根据实际需求进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值