坐标相关---------------------------
CGRect frame = CGRectMake(280, 12, 20, 20);
CGSize size=CGSizeMake(320,420);
CGPoint point=CGPointMake(30,60);
CGRect rect=[[UIScreen mainScreen] applicationFrame];
//获得屏幕可显示内容的最大显示区域(0,20,320,460)
//CGRect是结构体类型,不要用%@打印
CGRect screenRect=[self.view bounds];// 整个屏幕大小CGRect rect=self.view.bounds; CGSize
lineBreakMode:UILineBreakModeWordWrap];
//切页经典函数,根据给定的字体和大小范围,返回一个真实的大小
UIFont相关-----------------------
UIFont* font=[UIFont fontWithName:@"Arial" size:40.0f];//字体格式
UIFont *font = [UIFont systemFontOfSize:13];
NSArray*
label.text=(NSString*)font;
CGFloat oneLineHeigth=[@"a我W" sizeWithFont:font].height;
//取得一行高度,siezWithFont 返回的是一个CGSIZE类型
UILabel相关-----------------------
UILabel* label=[[UILabel alloc]
initWithFrame:CGRectMake(0, 0, realSize.width, realSize.height)];
UILabel* label=[[UILabel alloc] initWithFrame:CGRectZero];//不指定大小的初始化
label.numberOfLines=0;//设置最大行数,超过指定行则截断用省略号表示 ,默认为1,为0 表示不限制
label.lineBreakMode=UILineBreakModeCharacter
label.text=str;
label.textColor=[UIColor blueColor];
lable.textAlignment=UITextAlignmentCenter;//设置字体对齐方式
label.backgroundColor=[UIColor clearColor]; //设置label背景色
label.font=font;
label.frame=CGRectMake(0,0,1,1);
self.contentLabel=label;
int val=[label.text intValue];//NSString 到 intValue的转换
UILabel* label=(UILabel*)[self.view viewWithTag:100];
//每一个viewController 都有一个self.view,viewWithTag:100找出该
view上tag值为100的控件,返回值为UIView*类型
[self.view addSubview:self.contentLabel];
[label addSubview:img];
UIView相关--------------------
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(3, 3, 300, 40)];
view.backgroundColor=[UIColor clearColor];
for(UIView *subview in [cell.contentView subviews])//获取view的子视图
[subview removeFromSuperview];//从父视图中移除子视图
UIButton相关------------------------
UIButton *button;
button.frame=CGRectMake(280, 12, 20, 20);
button.tag=123
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"Pre" forState:UIControlStateNormal];
//UIButton设置标题 不是通过label.text而是用setTitle方法。很容易出错
button.alpha=0.5f;//设置透明
[button setBackgroundImage:[UIImageimageNamed:@"title.png"]
forState:UIControlStateNormal];//给buttton设置背景图片
addTarget:self action:@selector(headerClick:)
forControlEvents:UIControlEventTouchUpIns
//给控件手动增加响应动作