改变UIView的位置 [英] Changing the position of UIView
本文介绍了改变UIView的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要设置UIView的位置。下面的代码显示了我是如何做到的。但这行不通。我该怎么做?
I need to set the position of UIView. The code below shows how I do it. But it does not work. How do I do this?
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = myview.frame;
frame.origin.x = myview.frame.origin.x;
frame.origin.y = 0;
myview.frame = frame;
NSLog(@"%d", frame.origin.y );
}
推荐答案
UIView的一个中心属性。.如果要更改位置,则只需使用它即可...而不是调整整个视图的大小
UIView's have a center property..if you want to change the position then just use that... rather to resize whole view
myview.center = CGPointMake(50, 250);
希望对您有帮助。
这篇关于改变UIView的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文