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.

 

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

 

 

 

目录
相关文章
|
开发工具
UIView的clipsTobounds属性
UIView的clipsTobounds属性
93 0
UIView的clipsTobounds属性
|
容器
(三)UITabBarController和UITabBar的基本用法
(三)UITabBarController和UITabBar的基本用法
268 0
一个重要的类 CALayer
一个重要的类CALayer —— 基本概览(一)一个重要的类CALayer —— 其与UIView的区别(二)一个重要的类CALayer ——主要属性及其在显示图片中的简单应用(三)
762 0