Questions tagged [uibutton]

UIButton is a subclass of UIView for displaying buttons in iOS. It implements the target action paradigm to send events to the controller layer.

A UIButton intercepts touch events and sends an action message to a target object when tapped. Methods for setting the target and action are inherited from UIControl (). This class provides methods for setting the title, image, and other appearance properties of a UIButton. By using these accessors, you can specify a different appearance for each button state:

  • UIControlStateNormal,
  • UIControlStateHighlighted,
  • UIControlStateDisabled,
  • UIControlStateSelected.
  • UIControlStateFocused.

Resources:

11252 questions
28
votes
8 answers

How to disable UIButton highlight on click?

How to disable button highlight effect on click? Have custom button with white bg color and DarkGray text color. The problem is the text becomes white on button click. Already tried but none of them worked: a. Did uncheck "Highlighted Ajusts Image"…
Centurion
  • 14,106
  • 31
  • 105
  • 197
28
votes
9 answers

How to increase selection area of UIButton?

I have made the UIButton programmatically togglebutton = [UIButton buttonWithType:UIButtonTypeCustom]; togglebutton.frame = CGRectMake(42, 15, 80, 21); [togglebutton addTarget:self action:@selector(toggleview) …
Minkle Garg
  • 1,397
  • 3
  • 13
  • 27
28
votes
9 answers

UIButton title and image alignment query

I have a UIButton and I am trying to set a title and an image on it. I would like to align the title for a UIButton to the left side and place an image aligned to the right. I am trying to get the look and feel of the button in Timer in Clocks app…
siasl
  • 497
  • 1
  • 8
  • 17
28
votes
8 answers

how to set UIButton type in UIButton Subclass

I am subclassing the UIButton, what i want is to set the button type to Round Rect. Button.h @interface Button : UIButton {} - (void)initialize; @end Button.m @implementation Button - (id)initWithFrame:(CGRect)frame { self = [super…
Haris Hussain
  • 2,531
  • 3
  • 25
  • 38
27
votes
14 answers

UIButton setImage not working

I'm losing my mind over this one. I have UIButton connected as Outlet. I want to change it's image. In the viewDidLoad function, I try to set the image like so: [button1 setImage:[UIImage imageNamed:@"house.png"]…
detra83
  • 739
  • 1
  • 7
  • 10
27
votes
2 answers

iOS: UIButton titleLabel -- does it do anything at all?

I want to make a UIButton with type UIButtonTypeCustom (for the shape). I want to assign the title using button.titleLabel because I need to specify the font. The following code looks like it should work, but doesn't -- no label shows up,…
Amagrammer
  • 6,385
  • 3
  • 28
  • 30
27
votes
4 answers

Custom font title for UIButton

Is there a way to have custom fonts to the title of a button.
xydev
  • 3,409
  • 5
  • 34
  • 54
27
votes
2 answers

UIButton is not highlighting when pressed

My UIButton instance is not highlighting when pressed. I'm pretty sure my code is correct. This only happens in this specific class that I am using. I'm guessing because the function has been overridden by a protocol that I am conforming to. I want…
slimboy
  • 1,633
  • 2
  • 22
  • 45
27
votes
6 answers

How to make the UIButton background transparent?

I tried use a transparent png as a background, but not success. How can I solve it ? thz.
Tattat
  • 15,548
  • 33
  • 87
  • 138
27
votes
5 answers

Set a border for UIButton in Storyboard

I can't get a border onto my buttons in Xcode 5 without setting them directly in the code. Is it possible that there's no way to do this on the storyboard without making a custom background image?
Tommy Nicholas
  • 1,133
  • 5
  • 20
  • 31
27
votes
8 answers

Custom UIButton not highlighting when touched

I have a method that creates a custom UIButton that allows me to change the color of the button using QuartzCore. But the buttons don't highlight when touched. - (UIButton *)makeHeaderButton { UIButton *button = [UIButton…
Bob
  • 559
  • 1
  • 5
  • 18
26
votes
6 answers

Change background color of UIButton when Highlighted

Hi I want to change the UIButton background color which user Tap on the button. I am showing background color using gradient, when user tap I need to change the gradient color. [btn setTitle: @"Next" forState:UIControlStateNormal]; CAGradientLayer…
iPhoneDev
  • 2,995
  • 4
  • 33
  • 44
26
votes
1 answer

Custom UIButton + subviews = no events

Basically I have a custom UIButton and this custom button contains subviews. If I add those subviews to my UIButton, then the button stops responding to event changes. I.e if I tap on it it doesn't respond to the selector. I have everything set as…
user281300
  • 1,427
  • 2
  • 19
  • 31
26
votes
1 answer

Auto Layout error

I had a similar problem to this poster. And I used jrturton's suggestion to move the code for customizing the buttons into viewDidLayoutSubviews. It was working well until I received this error: 'NSInternalInconsistencyException', reason: 'Auto…
stumped
  • 3,235
  • 7
  • 43
  • 76
26
votes
6 answers

Change UIButton border color on highlight

I've got a simple custom UIButton, to which I added: button.layer.bordercolor = [[UIColor blueColor]CGColor]; However, I want to change the .bordercolor when the button is highlighted. I tried adding an action to the button's touchDown action that…
JohnWickham
  • 571
  • 1
  • 6
  • 15