创建ToolBar StackOverflow
CGRect frame, remain;
CGRectDivide(self.view.bounds, &frame, &remain, 44, CGRectMaxYEdge);
_toolbar = [[UIToolbar alloc] initWithFrame:frame];
// _toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithTitle:@"今天" style:UIBarButtonItemStyleDone target:self action:@selector(toolBarGotoToday)];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *button2=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"schedule_back"] style:UIBarButtonItemStylePlain target:self action:@selector(toolbarBackClick)];
[_toolbar setItems:[[NSArray alloc] initWithObjects:button1,spacer,button2,nil]];
// [_toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
// [self.view addSubview:_toolbar];
直接使用UIViewController里的toolBar
Related
圆形UIImageView imageView.layer.cornerRadius = imageView.width/2; imageView.layer.maskToBounds = YEA;