IOS学习 autolayout 动画 与文件夹拖拽截图
2016-03-23 23:50
423 查看
@interface
ViewController ()
@property (weak,
nonatomic) IBOutlet
UIView *redView;
@property (weak,
nonatomic) IBOutlet
NSLayoutConstraint *redTop;
//绑定约束
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent
*)event{
//只是修改约束
self.redTop.constant +=
50;
[UIView
animateWithDuration:0.5
animations:^{
//调用这个方法,可以刷新View上所有约束
[self.view
layoutIfNeeded];
}];
}
![](http://img.blog.csdn.net/20160323234906180?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](http://img.blog.csdn.net/20160323234919427?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
ViewController ()
@property (weak,
nonatomic) IBOutlet
UIView *redView;
@property (weak,
nonatomic) IBOutlet
NSLayoutConstraint *redTop;
//绑定约束
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent
*)event{
//只是修改约束
self.redTop.constant +=
50;
[UIView
animateWithDuration:0.5
animations:^{
//调用这个方法,可以刷新View上所有约束
[self.view
layoutIfNeeded];
}];
}
相关文章推荐
- iOS --GitHub上常用的一些第三方
- iOS开发之Bug(持续更新)
- 打开本应用在系统的设置页面
- 在iOS开发中为什么使用多线程以及多线程的使用
- iOS查错机制
- IOS开发之OC学习笔记(中)
- iOS tableView的用法
- iOS学习笔记(2)
- iOS项目小结
- iOS 上线的标准
- ios-控件的frame_center_bounds简单介绍
- iOS--Masonry的简单使用
- iOS 下拉刷新-上拉加载原理
- iOS 侧滑按钮的实现
- iOS 设计中实现Cell自定义滑块操作
- iOS中代理属性用Weak修饰
- iOS 代理与通知,kvc和kvo的区别
- iOS instancetype与id的比较
- iOS import,include和class的区别
- iOS 本地通知