Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize Button shape in ios 7.1

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.

like image 951
DareDevil Avatar asked Mar 12 '14 07:03

DareDevil


2 Answers

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

like image 136
Arun Avatar answered Nov 14 '22 23:11

Arun


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

like image 23
Preetam Jadakar Avatar answered Nov 15 '22 01:11

Preetam Jadakar