Navigation上的BarButton添加动画效果
来源:互联网 发布:mac应用程序删除 编辑:程序博客网 时间:2024/04/29 12:53
这个秘诀就是
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:<#(UIView *)#>];
然后在view上添加动画效果就好了。
这里view上要添加TapGesture
在viewController中的设置
self.navigationController.navigationBar.clipsToBounds = YES; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backViewTapped:)]; backView = [[BackView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)]; [backView addGestureRecognizer:tapGesture]; UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:backView]; [self.navigationItem setLeftBarButtonItem:backBarButton];
backView中加入一个imageView,在imageView上加动画
-(UIImageView *)imageView{ if(!_imageView){ _imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"back"]]; } return _imageView;}
-(void)move{ CABasicAnimation *animation = [CABasicAnimation animation]; animation.keyPath = @"transform"; animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5, 0, 0)]; animation.duration = 0.5; [self.imageView.layer addAnimation:animation forKey:nil]; }
再在viewController中调用move的方法
-(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear: animated]; [backView move];}
0 0
- Navigation上的BarButton添加动画效果
- 导航栏上的 barbutton放置button
- 给ViewController添加BarButton
- IOs-控件上添加动画效果
- iOS给Navigation的BarButton的加消息提醒角标
- iOS给Navigation的BarButton的加消息提醒角标
- Launcher 上的动画效果
- 为Navigation Header上的控件添加监听事件
- IOS 添加收藏的动画效果
- 给你的网页添加动画效果
- activity切换的时候添加动画效果
- MUI添加下拉刷新的动画效果
- android添加动画效果
- Fragment添加动画效果
- activity添加动画效果
- ViewPager 添加动画效果
- ViewPager添加动画效果
- VC应用程序上引用动画的效果
- OpenGL纹理贴图 JPEG纹理
- NNT
- 用VC++建立Windows 服务程序
- 手斧Linux – 从LFS到Funtoo (57)
- 继承——圆到圆柱
- Navigation上的BarButton添加动画效果
- 【无中生有】---12---运维与监控
- xml解析,hashmap解析二层xml
- 欢迎使用CSDN-markdown编辑器
- 剑指offer 42 - 翻转单词顺序 左旋转字符串
- MAPConfidenceScorer API
- 六月二十四
- 观察者模式(Observer Pattern)
- Node API