Customize Button shape in ios 7.1

眉间皱痕 提交于 2019-12-05 08:59:49

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

For your reference sample is attached Here

preetam

These features reflect on apples default button control(may be nav bar). You don't need to worry about,these features are not app specific but for all apps.

If you want to ignore, don't use default button, instead go with custom.

P.S. After editing question by OP:

You can't achieve this without using custom implementation.

For More:reference

Well you can make it custom type & use image according to the way you want to view that.

IF you use a UINavigationBar or UIToolbar as the of the button then you will get a slightly darker color of the bar's tint color.

Otherwise you can get an underline whats color matches the text color, so i think this should not bother you. Leave it as it is.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!