• 创建UIButton


    UIButtonCreate.h
    
    #import <UIKit/UIKit.h>
    
    @interface UIButtonCreate : UIButton
    
    /**
     *  创建UIButton
     *
     *  @param frame            frame
     *  @param title            title
     *  @param titleColor       titleColor
     *  @param backgroundImage  backgroundImage
     *  @param highlightedImage highlightedImage
     *  @param target           target
     *  @param selector         selector
     */
    - (void)createButtonWithbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage  Target:(id)target Selector:(SEL)selector;
    
    /**
     *  创建UIButton
     *
     *  @param frame            frame
     *  @param title            title
     *  @param titleColor       titleColor
     *  @param backgroundImage  backgroundImage
     *  @param highlightedImage highlightedImage
     *  @param image            image
     *  @param target           target
     *  @param selector         selector
     */
    - (void)createButtonWithImageAndbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage image:(UIImage *)image Target:(id)target Selector:(SEL)selector;
    
    /**
     *  创建UIButton
     *
     *  @param frame           frame
     *  @param title           title
     *  @param titleColor      titleColor
     *  @param backgroundColor backgroundColor
     *  @param target          target
     *  @param selector        selector
     */
    - (void)createNormalButton: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundColor:(UIColor *)backgroundColor Target:(id)target Selector:(SEL)selector;
    
    @end
     /****************************************************/
    
    UIButtonCreate.m
    #import "UIButtonCreate.h"
    
    @implementation UIButtonCreate
    
    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code
        }
        return self;
    }
    
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect
    {
        // Drawing code
    }
    */
    
    
    - (void)createButtonWithbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage  Target:(id)target Selector:(SEL)selector
    {
        [self setFrame:frame];
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self setBackgroundImage:backgroundImage forState:UIControlStateNormal];
        [self setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
        [self setBackgroundColor:[UIColor clearColor]];
        [self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    
    }
    
    - (void)createButtonWithImageAndbackgroundImage: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundImage:(UIImage *)backgroundImage highlightedImage:(UIImage *)highlightedImage image:(UIImage *)image  Target:(id)target Selector:(SEL)selector
    {
        [self setFrame:frame];
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self setBackgroundImage:backgroundImage forState:UIControlStateNormal];
        [self setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
        [self setImage:image forState:UIControlStateNormal];
        [self setBackgroundColor:[UIColor clearColor]];
        [self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    - (void)createNormalButton: (CGRect) frame title:(NSString *)title titleColor:(UIColor *)titleColor backgroundColor:(UIColor *)backgroundColor Target:(id)target Selector:(SEL)selector
    {
        [self setFrame:frame];
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self setBackgroundColor:backgroundColor];
        [self addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    @end
  • 相关阅读:
    组件间通信
    Android抓包方法(一)之Fiddler代理
    汉字转拼音
    post请求参数问题
    post请求参数设置
    swagger
    IfcPresentationDefinitionResource(介绍定义资源)
    Java计算两个日期之间的时间差(毫秒数)
    IfcPresentationAppearanceResource(外观定义资源)
    IfcMeasureResource(度量资源)
  • 原文地址:https://www.cnblogs.com/joesen/p/3780254.html
Copyright © 2020-2023  润新知