在ios 7.1中自定义按钮形状 [英] Customize Button shape in ios 7.1

查看:183
本文介绍了在ios 7.1中自定义按钮形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple已添加按钮形状 ios 7.1中的功能。但我需要禁用我的应用程序或更改其默认颜色,形状以匹配我的应用程序的UI。可以不使用自定义类型按钮吗?请帮帮我。

Apple has added Button shape feature in ios 7.1. But I need to make it disable for my app or change its default color, shape to match UI of my app. It is possible without using custom type button? Please help me.

推荐答案

按下子按钮,然后尝试你想要的形状....

Sub class the button and try which shape you want....

#import "YourButton.h"
#import <QuartzCore/QuartzCore.h>

@implementation YourButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}



- (void)awakeFromNib
{
    [super awakeFromNib];
    CALayer *mask = [CALayer layer];
    mask.contents = (id)[[UIImage imageNamed:@"ge.png"] CGImage]; // ge is the black & white png image
    CGSize size = self.frame.size;
    mask.frame = CGRectMake(0, 0, size.width, size.height);
    self.layer.mask = mask;
    [self.layer setMasksToBounds:YES];
}

@end

附上参考样本此处

这篇关于在ios 7.1中自定义按钮形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆