iOS UIButton创建

来源:互联网 发布:手机麦克风变声软件 编辑:程序博客网 时间:2024/06/11 22:32

#pragma mark 创建按钮,登录、注册按钮等

+ (UIButton *)createButtonWithColor:(UIColor *)color Title:(NSString *)title TitleColor:(UIColor *)titleColor HighlightedTitleColor:(UIColor *)highlightedColor Font:(UIFont *)font AndCornerRadius:(CGFloat)cornerRadius

{

    UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

    [button setBackgroundColor:color];

    [button setTitle:titleforState:UIControlStateNormal];

    [button setTitleColor:titleColorforState:UIControlStateNormal];

    [button setTitleColor:highlightedColorforState:UIControlStateHighlighted];

    [button.titleLabelsetFont:font];

    button.layer.cornerRadius = cornerRadius;

    

    return button;

}


//登录按钮loginButton 调用时

- (UIButton *)loginButton

{

    if (!_loginButton) {

        _loginButton = [UIToolcreateButtonWithColor:RGB(240,84, 84) Title:@"登录"TitleColor:[UIColorwhiteColor]HighlightedTitleColor:RGB(128,128, 128) Font:[UIFontsystemFontOfSize:15]AndCornerRadius:2.0];

        [_loginButtonaddTarget:selfaction:@selector(loginButtonClicked)forControlEvents:UIControlEventTouchUpInside];

    }

    return_loginButton;

}



0 0