nbs
nbs

Reputation: 573

Changing the size of a Round Button in Cocoa

Is there a way by which I can increase the size of a Round Button in Cocoa? I am doing a Cocoa Application in which one of the view contains some of the user's avatars. I would like to use a Round Button and set the images to it. But I can't find any way to increase the size of the Round Button.

Is there some way of doing it?

Upvotes: 2

Views: 2107

Answers (4)

NewStack
NewStack

Reputation: 990

To resize the Rounded Rect NSButton you need to customize and you need to draw your own button.

To solve your problem use Gradient button resize what you want and setImage:an image should be rounded rect. then make borderless button

[button setBordered: NO];

now it will appear like rounded rect button.

To remove gray highlight use

[[button cell] setHighlightsBy:0];

Upvotes: 1

Bharath
Bharath

Reputation: 324

In case you are using images, they try with UIButton's method setBackgroundImage:forState:.

With this method, whenever you change the frame, it will adjust the image according to that.

Upvotes: 0

sangony
sangony

Reputation: 11696

Try this...

UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 150, 60)];
myButton.enabled = YES;
myButton.backgroundColor = [UIColor lightGrayColor];
[myButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[myButton setTitle:@"My Button" forState:UIControlStateNormal];
[self.view addSubview:myButton];

Change the 150 and 60 values to alter the shape of your button.

Upvotes: 0

Imodeveloper
Imodeveloper

Reputation: 404

yourButton.frame = CGRectMake(0, 0, 20, 20);

//or

yourButton.frame = CGRectMake(0, 0, 40, 60);

//or

yourButton.frame = CGRectMake(0, 0, 100, 80);

Upvotes: 1

Related Questions