刷新UIBarButtonItem上的动画 [英] Refresh animation on UIBarButtonItem

查看:102
本文介绍了刷新UIBarButtonItem上的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UIBarButtonItem制作刷新动画,问题是不仅旋转而且将图像上下移动。

I am trying to make a "refresh" animation using a UIBarButtonItem, the problem is that is not only rotating but moving the image up and down a bit.

-(void)startRefreshButtonRotationAnimation {
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
    rotationAnimation.duration = 1;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 1000;
    UIView *view = self.navigationItem.rightBarButtonItem.customView;
    [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

- (void)stopRefreshButtonRotationAnimation {
    UIView *view = self.navigationItem.rightBarButtonItem.customView;
    [view.layer removeAllAnimations];
}


推荐答案

检查图像,确保图像的中心位于微调器的中心(因为看起来很可能不是)。
进入您喜欢的图像编辑软件并将其居中,确保在导出时不会截断透明区域。

Check the image, make sure that the image's center is in the center of the spinner (because it looks like it most likely isn't). Go into your favourite image editing software and center it, making sure that when you export, the transparent areas aren't clipped off.

这篇关于刷新UIBarButtonItem上的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆