Android直播头像动画,iOS 仿抖音直播头像缩放动画

6e0c21fe7ed2

效果图

仿抖音直播头像缩放效果, 简单写了demo, 思路简单, 直接用的递归重复调用, 呈上所有代码.

@interface YCXHeaderZoomViewController ()

@property (nonatomic,strong) UIView *borderZoomView; // 缩放的边框

@property (nonatomic,strong) UIView *imageView; // 缩放的头像

@property (nonatomic,assign) NSTimeInterval animateTime; // 动画时间

@end

@implementation YCXHeaderZoomViewController

- (void)viewDidLoad {

[super viewDidLoad];

[self customView];

}

- (void)customView {

self.animateTime = 0.4;

UIView *bgView = [[UIView alloc] init];

//bgView.backgroundColor = [UIColor lightGrayColor];

[self.view addSubview:bgView];

[bgView mas_makeConstraints:^(MASConstraintMaker *make) {

make.center.equalTo(self.view);

make.width.height.mas_equalTo(50);

}];

// 固定边框

UIView *borderView = [[UIView alloc] init];

borderView.layer.cornerRadius = 25;

borderView.layer.borderColor = [UIColor greenColor].CGColor;

borderView.layer.borderWidth = 1;

[bgView addSubview:borderView];

[borderView mas_makeConstraints:^(MASConstraintMaker *make) {

make.edges.equalTo(bgView);

}];

// 缩放边框

UIView *borderZoomView = [[UIView alloc] init];

borderZoomView.layer.cornerRadius = 25;

borderZoomView.layer.borderColor = [UIColor greenColor].CGColor;

borderZoomView.layer.borderWidth = 1;

[bgView addSubview:borderZoomView];

[borderZoomView mas_makeConstraints:^(MASConstraintMaker *make) {

make.edges.equalTo(bgView);

}];

self.borderZoomView = borderZoomView;

// 缩放头像

UIImageView *imageView = [[UIImageView alloc] init];

imageView.image = [UIImage imageNamed:@"datu"];

imageView.backgroundColor = [UIColor magentaColor];

imageView.layer.cornerRadius = 48/2.0;

imageView.layer.masksToBounds = YES;

[bgView addSubview:imageView];

[imageView mas_makeConstraints:^(MASConstraintMaker *make) {

make.left.top.offset(1);

make.bottom.right.offset(-1);

}];

self.imageView = imageView;

// 缩放动画

[self zoomView];

}

// 核心代码

- (void)zoomView {

// 具体缩放大小 效果根据需要自己调整

// 边框放大

[UIView animateWithDuration:self.animateTime+0.1 animations:^{

self.borderZoomView.transform = CGAffineTransformMakeScale(1.15, 1.15); // 边框放大

self.borderZoomView.alpha = 0.08; // 透明度渐变

} completion:^(BOOL finished) {

// 恢复默认

self.borderZoomView.transform = CGAffineTransformMakeScale(1, 1);

self.borderZoomView.alpha = 1;

}];

// imageView先缩小 再恢复

[UIView animateWithDuration:self.animateTime animations:^{

self.imageView.transform = CGAffineTransformMakeScale(0.88, 0.88); // 缩小

} completion:^(BOOL finished) {

[UIView animateWithDuration:self.animateTime animations:^{

self.imageView.transform = CGAffineTransformMakeScale(1, 1); // 放大

} completion:^(BOOL finished) {

// 重新调用

[self zoomView];

}];

}];

}

@end

--> 点赞有没有😃

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值