码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-06-25 20:56:07      阅读:521      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   http   color   

bubuko.com,布布扣

 

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];

 

 

 

Class hierarchy of UIResponder as well as subclasses of UIView and UIControl,布布扣,bubuko.com

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

标签:style   class   blog   code   http   color   

原文地址:http://www.cnblogs.com/davidgu/p/3805521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!