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 

     

     

  • 相关阅读:
    时隔三个月,不言谢归来了。学习播客继续更新日常所学。
    一个网易云音乐的外链URL简单的获取方法
    VisualStudioCode常用主题,与插件设置
    页面a标签统一跳转方法:base 标签
    Web前端开发规范(记录一):团队约定-基本原则
    JS中,正则表达式:match(/^(.*)(.)(.{1,8})$/)[3]分析
    Morgan模块使用
    Config模块使用
    MongoDB安装
    JSP-九大内置对象
  • 原文地址:https://www.cnblogs.com/10-19-92/p/4914909.html
Copyright © 2011-2022 走看看