码迷,mamicode.com
首页 > 其他好文 > 详细

toolbar

时间:2015-04-11 13:09:44      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

#import "ViewController.h"

 

@interface ViewController ()

@property (strong, nonatomic) IBOutlet UITextField *textfield;

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    UIDatePicker *date=[[UIDatePicker alloc]init];

    //设置只显示中文

    [date setLocale:[NSLocale localeWithLocaleIdentifier:@"zh-CN"]];

    //只显示日期

    date.datePickerMode=UIDatePickerModeDate;

    //当光标移到文本框时召唤时间选择器

    self.textfield.inputView=date;

    //创建工具条,设置工具条的颜色和frame

    UIToolbar *toorbar=[[UIToolbar alloc]init];

    toorbar.barTintColor=[UIColor orangeColor];

    toorbar.frame=CGRectMake(0, 0, 375, 44);

    //给工具条添加按钮

    UIBarButtonItem *item1=[[UIBarButtonItem alloc]initWithTitle:@"上" style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    UIBarButtonItem *item2=[[UIBarButtonItem alloc]initWithTitle:@"下" style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    

    UIBarButtonItem *item3=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

    UIBarButtonItem *item4=[[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    

    toorbar.items=@[item1,item2,item3,item4];

    //设置文本输入框键盘的辅助视图

    self.textfield.inputAccessoryView=toorbar;

    

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

}

-(void)click

{

    NSLog(@"实现跳转");

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

@end

 

toolbar

标签:

原文地址:http://www.cnblogs.com/linximu/p/4417486.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!