zoukankan      html  css  js  c++  java
  • 自定义 UIButotn

    全局定制TITextField

    参考代码

    @interface myButton : UIButton

    {

    }

    //+(id)myButton;

    @end

     

    @implementation myButton

    -(void)awakeFromNib

    {

        UIImage* image = [UIImage imageNamed:@"按钮-点击前.png"];

        image = [image stretchableImageWithLeftCapWidth:image.size.width/2.0ftopCapHeight:image.size.height/2.0f];

        [selfsetBackgroundImage:image forState:UIControlStateNormal];

        image = [UIImage imageNamed:@"按钮-点击后.png"];

        image = [image stretchableImageWithLeftCapWidth:image.size.width/2.0f topCapHeight:image.size.height/2.0f];    

        [selfsetBackgroundImage:image forState:UIControlStateHighlighted];        

        [self.titleLabelsetFont:[UIFontsystemFontOfSize:12]];

        [selfsetTitleShadowColor:[UIColorwhiteColor] forState:UIControlStateNormal];

        [selfsetTitleShadowColor:[UIColorblackColor] forState:UIControlStateHighlighted];

        [selfsetTitleColor:c_btn_grayforState:UIControlStateNormal];

        [selfsetTitleColor:c_whiteforState:UIControlStateHighlighted];

    }

     - (id)initWithFrame:(CGRect)frame

    {

        self = [superinitWithFrame:frame];

        if (self) {

            UIImage* image = [UIImage imageNamed:@"按钮-点击前.png"];

            image = [image stretchableImageWithLeftCapWidth:image.size.width/2.0f topCapHeight:image.size.height/2.0f];

            [selfsetBackgroundImage:image forState:UIControlStateNormal];

            image = [UIImage imageNamed:@"按钮-点击后.png"];

            image = [image stretchableImageWithLeftCapWidth:image.size.width/2.0f topCapHeight:image.size.height/2.0f];          

            [selfsetBackgroundImage:image forState:UIControlStateHighlighted];        

            [self.titleLabelsetFont:[UIFontsystemFontOfSize:12]];

            [self.titleLabel setShadowColor:[UIColor whiteColor]];        

            [selfsetTitleColor:c_btn_grayforState:UIControlStateNormal];

            [selfsetTitleColor:c_whiteforState:UIControlStateHighlighted]; 

            [selfsetTitleShadowColor:[UIColorwhiteColor] forState:UIControlStateNormal];

            [selfsetTitleShadowColor:[UIColorblackColor] forState:UIControlStateHighlighted];        

        }

        returnself;

    }

    @end

     

     

    THE END !

  • 相关阅读:
    【秒懂音视频开发】10_PCM转WAV
    【秒懂音视频开发】09_播放PCM
    【秒懂音视频开发】08_音频录制02_编程
    【秒懂音视频开发】07_音频录制01_命令行
    【秒懂音视频开发】06_Qt开发基础
    高考数学考点关联表[Ⅳ]
    高考数学考点关联表[Ⅲ]
    高考数学考点关联表[Ⅱ]
    高考数学考点关联表[Ⅰ]
    反比例函数
  • 原文地址:https://www.cnblogs.com/xingchen/p/2323978.html
Copyright © 2011-2022 走看看