延展: 状态栏 高度 24, 导航栏 高度 44, 工具栏 高度 49.
控件 预留 Padding/ UIEdgeInsets.
有意思
UIBarButtonItem * fixedButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target: tarObject action: nil ];
fixedButton.width = kScreenWidth/7;
tempToolBar.items = @[cancelButton, fixedButton, confirmButton] ;
1.jpg没有 预料到 左右 预留的 间距, 应该是 UITextField 的 inputAccsoryView 造成的。
And Then
2.jpg没想到 两个图片 中间 还有间距, 什么鬼。
+ (UIToolbar *)createAccessoryToolbarWithExeSel: (SEL ) exeSel withTarget: (id) tarObject withCancelSel: (SEL) cancelSel withExeBtnTag: (NSInteger ) exeTag
{
CGFloat theButtonWidth = (kScreenWidth-15*2 -10)/2;
UIToolbar * tempToolBar = [[UIToolbar alloc ] initWithFrame: CGRectMake(0, 0, kScreenWidth, 50) ];
tempToolBar.barStyle = UIBarStyleDefault;
tempToolBar.translucent = YES;
tempToolBar.backgroundColor = [ZheUtil colorWithHexString: @"#53C168" ];
tempToolBar.userInteractionEnabled = YES;
UIButton * confirmBtn = [UIButton buttonWithType: UIButtonTypeCustom ];
confirmBtn.frame = CGRectMake( 0 , 0, theButtonWidth, 50 ) ;
[confirmBtn setTitle: @"确定" forState: UIControlStateNormal ];
confirmBtn.titleLabel.font = [UIFont systemFontOfSize: 15 ];
[confirmBtn setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal ];
[confirmBtn addTarget: tarObject action: exeSel forControlEvents: UIControlEventTouchUpInside ];
confirmBtn.backgroundColor = [UIColor blueColor ];
confirmBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
confirmBtn.tag = exeTag;
UIBarButtonItem * confirmButton = [[UIBarButtonItem alloc ] initWithCustomView: confirmBtn ];
UIButton * cancelBtn = [UIButton buttonWithType: UIButtonTypeCustom ];
cancelBtn.frame = CGRectMake( 0 , 0, theButtonWidth, 50 ) ;
cancelBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
[cancelBtn addTarget: tarObject action: cancelSel forControlEvents: UIControlEventTouchUpInside ];
[cancelBtn setTitle: @"取消" forState: UIControlStateNormal ];
cancelBtn.titleLabel.font = [UIFont systemFontOfSize: 15 ];
[cancelBtn setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal ];
cancelBtn.backgroundColor = [UIColor magentaColor ];
UIBarButtonItem * cancelButton = [[UIBarButtonItem alloc ] initWithCustomView: cancelBtn ];
[tempToolBar setItems: @[cancelButton, confirmButton] animated: YES ];
return tempToolBar;
}
网友评论