animateWithDuration
2015-11-16 10:26
162 查看
1.frame, bounds ,center 三者之间的关系
frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)
bounds:该view在本地坐标系统中的位置和大小。(参照点是,本地坐标系统)
center:该view的中心点在父view坐标系统中的位置和大小。(参照电是,父亲的坐标系统)
搞iOS开发的童鞋基本都会用过UIView,那他的bounds和frame两个属性也不会陌生,那这两个有什么实质性的区别呢?
先看到下面的代码你肯定就明白了一些:
-(CGRect)frame{
return CGRectMake(self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
-(CGRect)bounds{
return CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
}
很明显,bounds的原点是(0,0)点,而frame的原点却是任意的。
2.animateWithDuration
duration 是动画的时间,而动画效果的最终位置是在animations 里面设置的。
3.CGPointMake ,CGRectMake
CGPoint: 表示一个二维坐标系中的点
CGSize: 表示一个矩形的宽度和高度
CGRect: 表示一个矩形的位置和大小
4.代码分析CGPoint:
表示一个二维坐标系中的点
- (void)show
{
[super show];//这个show 是否需要防止在后面呢?因为[super show]将contentview 已经加载到UIViews 上面去了。
CGRect frame =
self.contentView.frame;
self.contentView.frame =
CGRectMake(0, [UIScreen
mainScreen].bounds.size.height, frame.size.width,
frame.size.height);
[UIView
animateWithDuration:0.3
animations:^{
self.contentView.frame = frame;
} completion:^(BOOL finished) {
}];
}
- (void)dismiss
{ [UIView
animateWithDuration:0.3
animations:^{
self.contentView.frame =
CGRectMake(0, [UIScreen
mainScreen].bounds.size.height,
self.contentView.frame.size.width,
self.contentView.frame.size.height);
} completion:^(BOOL finished) {
[super
dismiss];
}];
}
frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统)
bounds:该view在本地坐标系统中的位置和大小。(参照点是,本地坐标系统)
center:该view的中心点在父view坐标系统中的位置和大小。(参照电是,父亲的坐标系统)
搞iOS开发的童鞋基本都会用过UIView,那他的bounds和frame两个属性也不会陌生,那这两个有什么实质性的区别呢?
先看到下面的代码你肯定就明白了一些:
-(CGRect)frame{
return CGRectMake(self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
-(CGRect)bounds{
return CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
}
很明显,bounds的原点是(0,0)点,而frame的原点却是任意的。
2.animateWithDuration
+ (void)animateWithDuration:([code]NSTimeInterval) durationanimations:( void (^ _Nonnull)(void)) animationscompletion:( void (^ _Nullable)(BOOL finished)) completion |
3.CGPointMake ,CGRectMake
CGPoint: 表示一个二维坐标系中的点
CGSize: 表示一个矩形的宽度和高度
CGRect: 表示一个矩形的位置和大小
4.代码分析CGPoint:
表示一个二维坐标系中的点
- (void)show
{
[super show];//这个show 是否需要防止在后面呢?因为[super show]将contentview 已经加载到UIViews 上面去了。
CGRect frame =
self.contentView.frame;
self.contentView.frame =
CGRectMake(0, [UIScreen
mainScreen].bounds.size.height, frame.size.width,
frame.size.height);
[UIView
animateWithDuration:0.3
animations:^{
self.contentView.frame = frame;
} completion:^(BOOL finished) {
}];
}
- (void)dismiss
{ [UIView
animateWithDuration:0.3
animations:^{
self.contentView.frame =
CGRectMake(0, [UIScreen
mainScreen].bounds.size.height,
self.contentView.frame.size.width,
self.contentView.frame.size.height);
} completion:^(BOOL finished) {
[super
dismiss];
}];
}
相关文章推荐
- C取整函数
- LeetCode Missing Number 数组
- gray code
- 利用ssh传输文件
- android 设置全屏与非全屏
- swift之switch续(元组,值绑定,where)
- jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动
- 在线预览文档openoffice+swfTool
- Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool
- xml文件里面出现unbound prefix的问题
- 11月12日全球六大国际域名解析量:.COM净增110.9万
- BUFFER解释
- Linux Mint 显卡驱动失败解决办法
- Git版本控制软件基本操作命令总结
- LeetCode:Symmetric Tree
- xib的简单使用
- 周_月
- Vue.js列表输出不同style
- leetcode Number of 1 Bits
- jquery easyui 技巧整理