-1

I want to make a roundrectangular button i applied the following code but its not working. Plz help me enter image description here

login = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    CGFloat xbuttonpadding = CGRectGetMinX(password.frame);
    CGFloat ybuttonpadding = CGRectGetMaxY(password.frame) + xpadding;
    CGFloat widthloginbutton = CGRectGetWidth(self.view.frame) - widthpassword;
    CGFloat heightloginbutton = CGRectGetHeight(username.frame) +10;
    login.frame= CGRectMake(xbuttonpadding, ybuttonpadding, widthloginbutton, heightloginbutton);
    login.backgroundColor = [UIColor blueColor];
    [login setTitle:@"login" forState:UIControlStateNormal];
    [login addTarget:self action:@selector(show:) forControlEvents:UIControlEventTouchUpInside];
  • 2
    possible duplicate of [How to round the corners of a button](http://stackoverflow.com/questions/5047818/how-to-round-the-corners-of-a-button) – Shamas S Sep 30 '15 at 09:09
  • 2
    `UIButtonTypeRoundedRect` was deprecated in iOS 7. Follow @ShamasS link to round the corners yourself. :) – Luke Sep 30 '15 at 09:11

2 Answers2

1

first of all import this in your .m file -

#import <QuartzCore/QuartzCore.h>

and then in your loadView method add following lines

yourButton.layer.cornerRadius = 10; // this value vary as per your desire
yourButton.clipsToBounds = YES;

Hope this works for you

0

try:

login.layer.cornerRadius = 0.5f;
login.clipsToBounds = YES;
Igor
  • 1,537
  • 10
  • 12