【发布时间】:2012-08-15 18:26:08
【问题描述】:
我想将 UIView 从右侧调整到左侧(相反)。
现在我有这样的矩形视图:CGRectMake(100.f, 0.f, 100.f, 100.f);
[UIView animateWithDuration:0.5 animations:^{
view.frame = CGRectMake(0.f, 0.f, 200.f, 100.f);
}];
问题是动画不好看。它向右弹跳(变大),然后移动到位置 0.0,0.0。
我想达到与从左到右调整大小时相同的效果。
编辑:代码
- (void)resizeSearchBar:(int)type
{
//resize - bigger
if (type == 1) {
[UIView animateWithDuration:1.0 animations:^{
self.searchBar.frame = CGRectMake(0.f, 0.f, 280.f, 44.f);
}];
}
//resize - smaller
else {
[UIView animateWithDuration:1.0 animations:^{
self.searchBar.frame = CGRectMake(95.f, 0.f, 185.f, 44.f);
}];
}
}
编辑 2
我也尝试过像这样更改 IB 中的视图属性:
仍然没有运气......
【问题讨论】:
-
你能显示窗口创建代码吗?你是从哪个方法开始这个动画的?实际上,您似乎试图为错误的“属性”设置动画......
-
其实我想调整 UISearchBar 的大小。它是从 nib 创建并连接到属性 self.mySearchBar
标签: iphone ios animation uiview