【发布时间】:2014-11-19 09:04:23
【问题描述】:
我有 UIViewA by Storyboard 和 (w,h,x,y)
我想通过代码更改大小UIViewA
我该怎么做?
【问题讨论】:
标签: ios storyboard
我有 UIViewA by Storyboard 和 (w,h,x,y)
我想通过代码更改大小UIViewA
我该怎么做?
【问题讨论】:
标签: ios storyboard
在您的 ViewController 类中为该 UIView 对象创建一个 IBOutlet 并在 ViewDidload 或您希望以编程方式设置框架的任何地方设置其框架。 注意:我假设您没有使用自动布局。
【讨论】:
[UIViewA setFrame:yourFrameWithChangedSize];
【讨论】:
试试这样 添加这个 .h
@property (strong,nonatomic) IBOutlet UIView *yourview;
在 .m 文件中
@synthesize yourview
根据需要创建视图
`yourview.frame = CGRectMake(10,100,300,40)`;
self.view = yourview;
在你需要的地方改变你的看法
yourview.frame = CGRectMake(102,200,300,40);
请参考link
【讨论】: