本来打算用文字的语言直接去描述,写了一会却发现这样的话文字量太大,作为一个很2B的≈程序小猫来说,还是觉得用代码来的比较划算!直接看代码,当然我总结的也不是很全,大家将就着看吧!感觉好的给个赞,感觉不好的给个鸡蛋!呵~- (void)viewDidLoad
{
[superviewDidLoad];
//UILabel的应用
UILabel *aLabel=[[UILabel alloc]initWithFrame:CGRectMake(100, 100, 150, 50)];//label的创建
[aLabel setText:@"豹子,你很帅!哈哈哈哈"];//设置内容
aLabel.textColor=[UIColor redColor];//字体颜色
aLabel.backgroundColor=[UIColor grayColor];//label背景颜色
aLabel.textAlignment=NSTextAlignmentCenter;//居中对齐
aLabel.userInteractionEnabled=YES;//用户交互
aLabel.highlightedTextColor=[UIColor yellowColor];//高亮颜色
aLabel.highlighted=NO;//字体是否高亮,当为yes时,字体为上面设置的黄色
aLabel.lineBreakMode=NSLineBreakByTruncatingMiddle;//字符截取,中间省略
aLabel.baselineAdjustment=UIBaselineAdjustmentAlignCenters;//文本区域text中间与label中间线对齐
aLabel.shadowColor=[UIColor blueColor];//阴影颜色
aLabel.shadowOffset=CGSizeMake(0, 2);//阴影偏移
[self.view addSubview:aLabel];//贴到父视图上展示
//UITextField的应用
UITextField *aTfied=[[UITextField alloc]initWithFrame:CGRectMake(100, 180, 150, 50)];//UITextField的创建
aTfied.borderStyle=UITextBorderStyleRoundedRect;//样式
aTfied.text=@"豹子,你真的真的很帅";//可以设置字体,也可以删除
aTfied.font=[UIFont systemFontOfSize:20];//字体大小
aTfied.placeholder=@"豹子,你帅呆了";//提示输入的文字
aTfied.textAlignment=NSTextAlignmentCenter;//文字居中对齐
aTfied.backgroundColor=[UIColor redColor];//背景颜色
[self.view addSubview:aTfied];//贴到父视图上展示
//UIButton的使用
UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];//button的创建
btn.frame=CGRectMake(100, 250, 150, 50);//button的大小
[btn setTitle:@"豹子"forState:UIControlStateNormal];//标题文字
[btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];//按下时的标题颜色
btn.font=[UIFont systemFontOfSize:20];//font这里已经被弃用,但还是可以使用的,只是不建议使用
btn.showsTouchWhenHighlighted=YES;//按下时发光
[btn addTarget:selfaction:@selector(put:) forControlEvents:UIControlEventTouchUpInside];//添加点击事件
[self.view addSubview:btn];//贴到父视图展示
}
-(void)put:(UIButton *)sender{
//UIActionSheet的使用
UIActionSheet *actSheet=[[UIActionSheet alloc]initWithTitle:@"豹子是不是帅哥?"delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:@"是"otherButtonTitles:@"不是",nil];
[actSheet showInView:self.view];//
}
-(void)showAlert1:(NSString *)msg{
//UIAlertView的使用
//创建alert内容
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"你是个好人!哈哈"delegate:self cancelButtonTitle:@"返回"otherButtonTitles:nil,nil];
[alert show];//这条语句用来显示Alert
}
-(void)showAlert2:(NSString *)msg{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"粑粑说:说谎话找不到老婆,而且自己的比别人的短!"delegate:selfcancelButtonTitle:@"返回"otherButtonTitles:nil, nil];
[alert show];
}
//以下这个方法,来自UIActionSheetDelegate自身的方法,具体的可以看API,在这个方法里,给自己设置的按钮添加事件
-(void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex==0) {
[selfshowAlert1:@"确定"];
}else if(buttonIndex==1){
[selfshowAlert2:@"确定"];
}
}
//UIActivityIndicatorView的使用,活动指示器视图
UIActivityIndicatorView *indView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];//创建进度轮并设置样式
indView.center=self.view.center;//设置视图的位置,显示在主视图的中心
[self.view addSubview:indView];//添加视图到父视图上
[indView startAnimating];//开始显示进度轮动画
//想要结束并隐藏进度轮,只要使用[indViewstopAnimating]; 或hidesWhenStopped设置为yes,就可以了。
//UIImageView的使用
//创建图片视图
UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,320, 480)];
imgView.tag=10;
//创建一个图像对象
NSString *imgFilePath=[[NSBundle mainBundle]pathForResource:@"12"ofType:@"jpg"];
UIImage *img=[[UIImage alloc]initWithContentsOfFile:imgFilePath];
//设置图片视图的图像
imgView.image=img;
//[self.view addSubview:imgView];//将视图添加到父视图中
//UIScrollView滚动视图的使用
//UIScrollView是UITableView和UITextView的超类
UIScrollView *sview=[[UIScrollView alloc]initWithFrame:self.view.frame];//创建滚动视图
sview.tag=20;
sview.delegate=self;//设置代理
sview.indicatorStyle=UIScrollViewIndicatorStyleWhite;//滚动样式
//view加载后,立即横向移动300像素
[sview setContentOffset:CGPointMake(300,0) animated:YES];
//不显示水平滚动条
sview.showsHorizontalScrollIndicator=NO;
//设置此属性后,滚动内容将以页为单位进行滚动。
sview.pagingEnabled=YES;
sview.contentSize=CGSizeMake(687, 343);
[sview addSubview:imgView];//把图片贴到滚动视图上
[self.view addSubview:sview];//滚动视图贴父视图上
//UIPageControl分页控件的使用
UIPageControl *pc=[[UIPageControl alloc]initWithFrame:CGRectMake(50,333, 220,137)];//创建分页控件
pc.numberOfPages=2;//设置总页数
[pc addTarget:selfaction:@selector(pageMathod:) forControlEvents:UIControlEventValueChanged];//添加事件处理,这里主要展示的是控件的如何使用,就不粘贴这个事件的代码了哈!
[self.view addSubview:pc];
手敲的有点累,未完待续、、、、、、