zoukankan      html  css  js  c++  java
  • iOS-UIButton-文字位置,字体大小,边角样式,button种类,点击事件,内容位置

    一. 设置button的文字居左,居中,居右
    //设置button居左
    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置button的内间距为居左10个像素点
    button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    二.设置button的字体大小
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    三.设置button的圆角样式
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius =5.0f;
    四.Button的种类
    /**(UIButtonType)
             UIButtonTypeCustom                              自定义风格
             UIButtonTypeSystem                              系统风格
             UIButtonTypeDetailDisclosure                    蓝色小箭头按钮
             UIButtonTypeInfoLight                           亮色感叹号
             UIButtonTypeInfoDark                            暗色感叹号
             UIButtonTypeContactAdd                          十字加号按钮
             UIButtonTypeRoundedRect = UIButtonTypeSystem    圆角按钮
    */
    五.Button的状态
    /**(UIControlState)
             UIControlStateNormal                            常规状态下显示
             UIControlStateHighlighted 高亮状态下显示
             UIControlStateSelected  选中状态
             UIControlStateDisabled  禁用状态下显示
             UIControlStateApplication  = 0x00FF0000    当应用程序标志时
             UIControlStateReserved     = 0xFF000000     为内部框架预留,可以不用管它
    */
    六.Button的点击事件
    /**(UIControlEvents)
             UIControlEventTouchDown
             单点触摸按下事件:用户点触屏幕,或者又有新手指落下的时候。
             UIControlEventTouchDownRepeat
             多点触摸按下事件,点触计数大于1:用户按下第二、三、或第四根手指的时候。
             UIControlEventTouchDragInside
             当一次触摸在控件窗口内拖动时。
             UIControlEventTouchDragOutside
             当一次触摸在控件窗口之外拖动时。
             UIControlEventTouchDragEnter
             当一次触摸从控件窗口之外拖动到内部时。
             UIControlEventTouchDragExit
             当一次触摸从控件窗口内部拖动到外部时。
             UIControlEventTouchUpInside
             所有在控件之内触摸抬起事件。
             UIControlEventTouchUpOutside
             所有在控件之外触摸抬起事件(点触必须开始与控件内部才会发送通知)。
             UIControlEventTouchCancel
             所有触摸取消事件,即一次触摸因为放上了太多手指而被取消,或者被上锁或者电话呼叫打断。
             UIControlEventTouchChanged
             当控件的值发生改变时,发送通知。用于滑块、分段控件、以及其他取值的控件。你可以配置滑块控件何时发送通知,在滑块被放下时发送,或者在被拖动时发送。
             UIControlEventEditingDidBegin
             当文本控件中开始编辑时发送通知。
             UIControlEventEditingChanged
             当文本控件中的文本被改变时发送通知。
             UIControlEventEditingDidEnd
             当文本控件中编辑结束时发送通知。
             UIControlEventEditingDidOnExit
             当文本控件内通过按下回车键(或等价行为)结束编辑时,发送通知。
             UIControlEventAlltouchEvents
             通知所有触摸事件。
             UIControlEventAllEditingEvents
             通知所有关于文本编辑的事件。
             UIControlEventAllEvents
             通知所有事件。
    */
    七.Button的属性
    1.设置Button竖直方向上内容的位置
    //self.btn1.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
            /**
             UIControlContentVerticalAlignmentCenter  = 0,
             UIControlContentVerticalAlignmentTop     = 1,
             UIControlContentVerticalAlignmentBottom  = 2,
             UIControlContentVerticalAlignmentFill    = 3,
             */
    2.设置Button水平方向上内容的位置
     self.btn1.contentHorizontalAlignment =  UIControlContentHorizontalAlignmentLeft;
     self.btn1.contentEdgeInsets = UIEdgeInsetsMake(20, 20, 0, 0);
            /**contentHorizontalAlignment:
                UIControlContentHorizontalAlignmentCenter = 0,
                UIControlContentHorizontalAlignmentLeft   = 1,
                UIControlContentHorizontalAlignmentRight  = 2,
                UIControlContentHorizontalAlignmentFill   = 3,
             */
    3.设置Button的标题内边距
    self.btn1.titleEdgeInsets = UIEdgeInsetsMake(20, 50, 0, 0);
    八.Button的 imageEdgeInsets和 titleEdgeInsets属性
    你的一次推荐就是对我莫大的支持。感觉不错,给个推荐或者评论吧。
  • 相关阅读:
    Nginx负载均衡+代理+ssl+压力测试
    Nginx配置文件详解
    HDU ACM 1690 Bus System (SPFA)
    HDU ACM 1224 Free DIY Tour (SPFA)
    HDU ACM 1869 六度分离(Floyd)
    HDU ACM 2066 一个人的旅行
    HDU ACM 3790 最短路径问题
    HDU ACM 1879 继续畅通工程
    HDU ACM 1856 More is better(并查集)
    HDU ACM 1325 / POJ 1308 Is It A Tree?
  • 原文地址:https://www.cnblogs.com/mancong/p/5013847.html
Copyright © 2011-2022 走看看