有关UIView,UIButton,UITabBarItem,UITabBarController的基础

UIView相关--------------------       

           UIView*view=[[UIView alloc]initWithFrame:CGRectMake(3, 3, 300, 40)];

           view.backgroundColor=[UIColorclearColor];  //设置view的背景色为透明色

          

for(UIView*subview in [cell.contentView subviews])//获取view的子视图      

                    / /UITabViewCell中的contentView包括textlabel和imageView

                     [subviewremoveFromSuperview];//从父视图中移除子视图

          

 

UIButton相关------------------------

 

           UIButton*button;

           button.frame=CGRectMake(280,12, 20, 20);

           button.tag=123

           UIButton*button=[UIButton buttonWithType:UIButtonTypeCustom];

         //UIButton的默认类型为自定义类型UIButtonTypeCustom,此类型UIBUTTON没有图示,看不见,但是能感应事件常用来感应响应事件。因为默认是不可见,所以手动写的时候,一定要修改其类型。

 

           [buttonsetTitle:@"Pre"forState:UIControlStateNormal];

//UIButton设置标题不是通过label.text而是用setTitle方法。很容易出错

 

           button.alpha=0.5f;//设置透明

 

[button setBackgroundImage:[UIImageimageNamed:@"title.png"]

forState:UIControlStateNormal];//给buttton设置背景图片

 

             [button

addTarget:self action:@selector(headerClick:)

forControlEvents:UIControlEventTouchUpInside];

//给控件手动增加响应动作

 

          

 

 

 

 

UITabBarItem----------------------

  //UITabBarItem是导航视图下面的对多五个,的小方块

 

           UITabBarItem*tabBar=[[UITabBarItem alloc]

initWithTitle:@"机票查询"

image:[UIImage imageNamed:@"near.png"]

tag:4];

 

   //初始化UITabBarItem

           UITabBarItem*tabBar5=[[UITabBarItem alloc]

initWithTabBarSystemItem:UITabBarSystemItemMoretag:5

tag:3];

//用系统给定的方式初始化initWithTabBarSystemItem:UITabBarSystemItemMore

 

UITabBarController-----------------------------

  //导航下部就是UITabBarController

           UITabBarController*tabBarController

           tabBarController.viewControllers=allTabs;//allTabs为包含viewController的数组

           tabBarController.selectedIndex=2  //指定开机默认为选中哪一个

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值