iOS开发中Date Picker和UITool Bar控件的使用简介

2020-01-14 18:20:05王旭

 

这里需要看一下initWithCustomView的定义:

复制代码
- (id)initWithCustomView:(UIView *)customView
可以看出,它的参数是一个VIEW,所以我们给它的配料要正确哦才行哦,否则,你就等着时间DIDADIDA的流失吧.

 

A>加一个开关switch:

复制代码
[myToolBarItems addObject:[[[UIBarButtonItem alloc]    

 

                                initWithCustomView:[[[UISwitch alloc] init] autorelease]] 

                                    autorelease]];  


B>加一个按钮UIBarButtonItem
复制代码
UIBarButtonItem *myButton = [[[UIBarButtonItem alloc] 

 

                                 initWithTitle:@"myButton" 

                                 style:UIBarButtonItemStyleBordered 

                                 target:self  

                                 action:@selector(action)]autorelease];