ios UIView animateWithDuration 学习
2015-10-16 16:19
519 查看
以下代码实现的效果:下滑到某一高度后自动隐藏掉
原始效果1
原始效果2 慢慢的下滑
原始效果3 隐藏消失
原始效果1
原始效果2 慢慢的下滑
原始效果3 隐藏消失
#pragma mark -- UIView animateWithDuration - (void)initTestBtn { _testBtn = [[UIButton alloc]initWithFrame:CGRectMake(15, 230, kDEVICEWIDTH-30, 45)]; _testBtn.backgroundColor = [UIColor grayColor]; [_testBtn addTarget:self action:@selector(commitClick) forControlEvents:UIControlEventTouchUpInside]; [_testBtn setTitle:@"提交" forState:UIControlStateNormal]; _testBtn.titleLabel.textColor = [UIColor whiteColor]; _testBtn.layer.cornerRadius = 4; [self.view addSubview:_testBtn]; // _testView = [[UIView alloc]initWithFrame:CGRectMake(15, 300, kDEVICEWIDTH-30, 45)]; // _testView.backgroundColor = [UIColor grayColor]; // // [self.view addSubview:_testView]; // [_testView addSubview:_testBtn]; } - (void)testAnimateWithDuration { /*typeof(self) 是获取到self的类型,这样定义出的weakSelf就是和self一个类型的, 加上__weak是建立一个若引用,整句就是给self定义了一个若引用性质的替身; 这个一般用在使用block时会用到,因为block会copy它内部的变量,可能会造成引用循环,使用__weak性质的self替代self,可以切断block对self的引用,避免循环引用*/ __weak __typeof(self) weakSelf = self; CGRect _tempCG = _testBtn.frame; _tempCG.origin.y = 360; [UIView animateWithDuration:1.5 animations:^{ //_testBtn.frame = CGRectMake(15, kDEVICEHEIGHT, kDEVICEWIDTH-30, 45); _testBtn.frame = _tempCG; } completion:^(BOOL finished) { _testBtn.hidden = YES; }]; }
相关文章推荐
- AndroidUI--SimpleAdapter CursorAdapter
- Leetcode:unique_binary_search_trees
- 记录使用Buildbot遇到的坑
- Mechanize Guide
- Retrofit(2.0)入门小错误 -- Could not locate ResponseBody xxx Tried: * retrofit.BuiltInConverters
- java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
- FDStackView —— Downward Compatible UIStackView (Part 1)
- 【UIAlertView警报和UIActionSheet操作表】
- Android UI组件的动态更新
- EasyUI加载内嵌json数据方法
- Handler post()等在子线程中更新主线程的UI的方法使用小汇
- Do odex for prebuilt apk in kitkat
- druid连接池配置
- UIStackView如何让你的开发更简单
- IOS8以上版本,使用UIAlertController代替 UIActionSheet和UIAlertView
- iOS开发UI篇—Quartz2D使用(绘制基本图形)
- JAVA学习3_Java多线程-工具篇-BlockingQueue
- iOS开发UI篇—Quartz2D(自定义UIImageView控件)
- iOS开发UI篇—核心动画(UIView封装动画)
- iOS开发UI篇—核心动画(转场动画和组动画)