首页 > 代码库 > Class hierarchy of UIResponder as well as subclasses of UIView and UIControl
Class hierarchy of UIResponder as well as subclasses of UIView and UIControl
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 propertyCGRect frame = label.frame;frame.origin.x = 10;frame.size.width = 200;[label setFrame:frame];
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。