您的位置:首页 > 产品设计 > UI/UE

Class hierarchy of UIResponder as well as subclasses of UIView and UIControl

2014-06-24 10:16 555 查看


When you were dragging in your label and your button to this view, you were adding them as subviews.
By doing this programmatically you can see what goes into adding a subview. You’d
need to pass in a frame to the alloc:initWithFrame: method, which is found on
most UIView subclasses:

CGRect frame = CGRectMake(0,0,100,20);
UILabel *label = [[UILabel alloc] initWithFrame:frame];

// To add this label to its parent view within a view controller, all you have to
// do is use the addSubView: function.
[self.view addSubView:label];

// Retrieving the frame, making a change to its size or origin, and then
// resetting its frame property
CGRect frame = label.frame;
frame.origin.x = 10;
frame.size.width = 200;
[label setFrame:frame];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐