美文网首页
控件的 进一步 认识: inputAccsoryView

控件的 进一步 认识: inputAccsoryView

作者: plantAtree_dAp | 来源:发表于2017-03-13 20:49 被阅读7次

    延展: 状态栏 高度 24, 导航栏 高度 44, 工具栏 高度 49.

    控件 预留 Padding/ UIEdgeInsets.

    有意思

    UIBarButtonItem * fixedButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target: tarObject action: nil ];
        fixedButton.width = kScreenWidth/7;
    
    

    
    tempToolBar.items = @[cancelButton, fixedButton, confirmButton] ;
    

    没有 预料到 左右 预留的 间距, 应该是 UITextField 的 inputAccsoryView 造成的。

    1.jpg

    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;
    }
    

    OK 了, 自己算出来的。

    1.jpg

    相关文章

      网友评论

          本文标题:控件的 进一步 认识: inputAccsoryView

          本文链接:https://www.haomeiwen.com/subject/zzmqnttx.html