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
3
votes
2 answers

Swift - Attributed strings in buttons

I have some UIbuttons in my app that have a number indicator before the text. Right now, I am just using string interpolation to display the number before the string as seen below. fruitButton.setTitle("\(fruitCounter) Fruits", forState:…
Joe
  • 3,772
  • 3
  • 33
  • 64
3
votes
4 answers

Apply CAShapeLayer to main UIView except UIButton

Here is a code which applying mask to the whole UIView: UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:self.view.bounds]; [maskPath appendPath:[UIBezierPath bezierPathWithArcCenter:self.mapCardsButton.center …
Serge
  • 2,031
  • 3
  • 33
  • 56
3
votes
3 answers

keep 3 UIbuttons center aligned using autolayout

I have a UIView with 3 UIButtons and what I want is when I hide one button I want other two buttons to centrally aligned with equal margin. Let say if there are 3 buttons the UI should be Like If there are 3 buttons --------------- [ ][ ][ …
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
3
votes
2 answers

Pixelated UIButton edges

I'm using Storyboard and I created a UIButton with a custom image. I have a problem that the edges of the button are pixelated: Image: Any idea? Thank you!
FS.O
  • 403
  • 6
  • 24
3
votes
2 answers

Assigning "aspect fill" option for background image of uibutton Swift

We can set the image of the button to be of aspect fill by : imageView?.contentMode = UIViewContentMode.ScaleAspectFill but since I am dealing with the background image, I'm not sure how to access contentMode for the background image. I know that…
mir-aclewhip
  • 127
  • 2
  • 11
3
votes
3 answers

change UIButton text with another UIButton text (swift)

My question is how to change UIButton's title with another UIButton's title. I have three buttons and I want to exchange title for button 1 and 3 with each other when I click on button 2. Look at this image and you will understand. how can I do…
J.S.O
  • 111
  • 1
  • 13
3
votes
4 answers

How do I stop multiple UIButton pressing?

Imagine I have a UIView and to that I add 2 UIButtons. I find that I can put a finger on one button, then, holding the first, I can touch the 2nd button with another finger. Both buttons will show their UIControlStateHighlighted images. Is there a…
3
votes
2 answers

Prevent users from pressing a button x times per second

I have a UIButton within an app that will allow the user to send a request to an API. How can I prevent the user from pressing this button more than X times per second?
XCode Warrier
  • 765
  • 6
  • 20
3
votes
1 answer

fade/show UIButton when scroll down/up

I have a tableView. on view is UIButton. i want when scroll down button fade and when scroll stop or up button show. code: - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{ NSLog(@"Start scroll"); //I assume the buttons are…
Sina
  • 849
  • 9
  • 21
3
votes
1 answer

iPhone 6s not receiving any touches on UIButtons

My Application works on every device except some iPhone 6s. When user tries to tap on buttons nothing happens. I checked Buttons frames and everything is right but still nothing happens when user taps on buttons. I think this is something touch…
BhushanVU
  • 3,455
  • 1
  • 24
  • 33
3
votes
0 answers

UIButton with custom image not highlighting on touch

I have a UIButton, and i am setting the image like this: UIImage *menu = [UIImage imageNamed:@"menu-bar-button-item"]; UIImage *menuTemplate = [menu imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; UIImage *menuOnTouch = [menu…
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
3
votes
1 answer

How can I detect a touch entering the frame of a UIButton?

I'm writing a class that implements a piano keyboard. Right now it's just a UIView and each key is a UIButton. I'd like the user to be able to drag their finger and hit several keys, but right now it only registers touch down. I've added…
Luke
  • 7,110
  • 6
  • 45
  • 74
3
votes
4 answers

Animated moving UIButton not responding to touches/taps while moving

I'm trying to animate a UIButton to move up the screen. At any point the user can touch it. However, it doesn't seem to respond to touches while moving, only at the start and end of its animation. I guess this is because the button itself isn't…
Smikey
  • 8,106
  • 3
  • 46
  • 74
3
votes
1 answer

Swift 3D Touch Force Value in UIButton

how can I measure the 3D touch force applied to a UIButton function? I want to use it for changing the volume of an AVAudioPlayer property in swift.
jesus
  • 69
  • 8
3
votes
5 answers

Change alpha of imageview of UIButton

Is there any way to change alpha of UIButton's imageview? I already tried subclassing UIButton and do below code, but it doesn't work. self.imageView.alpha = 0.0; I know it can be done by adding external UIImageView as a subview to UIButton but I…
sanjana
  • 3,034
  • 2
  • 25
  • 31