zoukankan      html  css  js  c++  java
  • UI控件之--UIButton

    UIButton是UIControl子类,这个类提供了方法来设置标题,图像,按钮等外观属性。通过使用set方法,你可以指定一个不同的外观为每个按钮状态。

    // typedef enum {
    // UIButtonTypeCustom = 0, 自定义风格
    // UIButtonTypeRoundedRect, 圆角矩形
    // UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
    // UIButtonTypeInfoLight, 亮色感叹号
    // UIButtonTypeInfoDark, 暗色感叹号
    // UIButtonTypeContactAdd, 十字加号按钮
    // } UIButtonType;

    + (id)buttonWithType:(UIButtonType)buttonType;

       // contentEdgeInsets : 切掉按钮内部的内容

        // imageEdgeInsets : 切掉按钮内部UIImageView的内容

        // titleEdgeInsets : 切掉按钮内部UILabel的内容

        shareButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);

    UIEdgeInsets contentEdgeInsets; // default is UIEdgeInsetsZero
    UIEdgeInsets titleEdgeInsets;                // default is UIEdgeInsetsZero
    BOOL         reversesTitleShadowWhenHighlighted; // default is NO. if YES, shadow reverses to shift between engrave and emboss appearance
    UIEdgeInsets imageEdgeInsets;                // default is UIEdgeInsetsZero
    BOOL         adjustsImageWhenHighlighted;    // default is YES. 默认情况下,当按钮高亮的情况下,图像的颜色会被画深一点,如果这下面的这个属性设置为no,那么可以去掉这个功能
    BOOL         adjustsImageWhenDisabled;       // default is YES. 默认情况下,当按钮禁用的时候,图像会被画得深一点,设置NO可以取消设置
    BOOL         showsTouchWhenHighlighted;      // default is NO. 设置为yes的状态下,按钮按下会发光
    UIColor     *tintColor; // The tintColor is inherited through the superview hierarchy. See UIView for more information.
    UIButtonType buttonType;

      

    - (void)setTitle:(NSString *)title forState:(UIControlState)state    //设置标题              

    - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state   //设置标题颜色

    - (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state  //设置标题阴影颜色

    - (void)setImage:(UIImage *)image forState:(UIControlState)state;            //设置图片

    - (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state    //设置背景图片

    - (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)state  // 设置标题 ,标题被设定为单行,,

     

    @property(nonatomic,readonly,retain) UILabel     *titleLabel   // 直接设置titleLabel属性不显示,原因是titleLabel的frame默认是0,hidden=yes;

    @property(nonatomic,readonly,retain) UIImageView *imageView 

     

     

  • 相关阅读:
    java生成压缩文件
    设计模式读书笔记-----外观模式
    设计模式读书笔记-----适配器模式
    设计模式读书笔记-----命令模式
    SpringMVC学习笔记七:SpringMVC统一异常处理
    SpringMVC学习笔记六:使用 hibernate-validator注解式数据校验
    SpringMVC学习笔记六:使用Formatter解析或格式化数据
    SpringMVC学习笔记五:使用converter进行参数数据转换
    SpringMVC学习笔记二:常用注解
    SpringMVC学习笔记四:数据绑定
  • 原文地址:https://www.cnblogs.com/10-19-92/p/4914909.html
Copyright © 2011-2022 走看看