控件的 进一步 认识 Draft

UIToolBar 的 自带 属性 与 功能, 我又用不上。
直接 整一个 UIView, 上面 两个按钮,

+ (UIToolbar *)createAccessoryToolbarWithExeSel: (SEL ) exeSel withTarget: (id) tarObject withCancelSel: (SEL) cancelSel withExeBtnTag: (NSInteger ) exeTag
{
    
    UIToolbar * tempToolBar = [[UIToolbar alloc ] initWithFrame: CGRectMake(0, 0, kScreenWidth,  50) ];
    tempToolBar.barStyle =  UIBarStyleDefault;
    tempToolBar.translucent = YES;
    tempToolBar.barTintColor = [ZheUtil colorWithHexString: @"#53C168" ];
    tempToolBar.userInteractionEnabled = YES;
    
    UIButton * confirmBtn = [ZheUtil parseToolBarBtnWithTitle: @"确定" ];
    [confirmBtn addTarget: tarObject action: exeSel forControlEvents: UIControlEventTouchUpInside ];
    confirmBtn.tag = exeTag;
    UIBarButtonItem * confirmButton = [[UIBarButtonItem alloc ] initWithCustomView: confirmBtn ];
    
    UIButton * cancelBtn = [ZheUtil parseToolBarBtnWithTitle: @"取消" ];
    [cancelBtn addTarget: tarObject action: cancelSel forControlEvents: UIControlEventTouchUpInside ];
    UIBarButtonItem * cancelButton = [[UIBarButtonItem alloc ] initWithCustomView: cancelBtn ];
    
    [tempToolBar setItems: @[cancelButton, confirmButton] animated: YES ];
    
    return tempToolBar;
}
+ (UIButton *) parseToolBarBtnWithTitle: (NSString *) titleStr
{
    CGFloat theButtonWidth = (kScreenWidth-15*2 -10)/2;
    UIButton * tempBtn = [UIButton buttonWithType: UIButtonTypeCustom ];
    tempBtn.frame = CGRectMake( 0 , 0, theButtonWidth, 50 ) ;
    tempBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    [tempBtn setTitle: titleStr forState: UIControlStateNormal ];
    tempBtn.titleLabel.font = [UIFont systemFontOfSize: 15 ];
    [tempBtn setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal ];
//    tempBtn.backgroundColor = [UIColor magentaColor ];

    return tempBtn;


}

ZheUtil

+ (UIToolbar *)createAccessoryToolbar
{
    UIToolbar * tempToolBar = [[UIToolbar alloc ] initWithFrame: CGRectMake(0, 0, kScreenWidth,  50) ];
    tempToolBar.barStyle =  UIBarStyleDefault;
    tempToolBar.translucent = YES;
    tempToolBar.backgroundColor = [ZheUtil colorWithHexString: @"#53C168" ];
    
    tempToolBar.userInteractionEnabled = YES;
    return tempToolBar;
}


你可能感兴趣的:(控件的 进一步 认识 Draft)