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

UICollectionView showing array of buttons Swift

I've been trying to figure out how i can use a UICollectionView to display an array of UIButtons. Each button has its own (different) action, image, title etc. When a button (which covers the entire cell in the collection view) is pressed that…
Matt Wyeth
  • 1,124
  • 2
  • 10
  • 19
3
votes
2 answers

UIButton label not showing

I have the following code let width = UIScreen.mainScreen().bounds.width let linkLabel = UILabel(frame: CGRect(x: 8, y: contentHeight, width: 100, height: labelHeight)) let linkButton = UIButton(frame: CGRect(x: 108, y: contentHeight, width:…
Andrey M.
  • 3,021
  • 29
  • 42
3
votes
0 answers

How to override gesture recognizer on UIButton to allow tap events to bubble to superview?

CustomButton, a subclass of UIButton, is embedded in CustomView, which is a UIView subclass. Tap events on CustomButton do not bubble to CustomView, because per the Apple docs: In iOS 6.0 and later, default control actions prevent overlapping …
Crashalot
  • 33,605
  • 61
  • 269
  • 439
3
votes
1 answer

Custom UIButton focus not working properly in tvOS

I have a UIViewController like this +View button1 button2 backgroundImage ScrollView scrollBackgroundImage scrollButton1 scrollButton2 All the buttons are of custom type if…
3
votes
6 answers

tintColor of UIButton's ImageView is not changing

How to change tintColor of button.imageView. If I use the same image in UIImageView with the same rendering mode as below the tintColor will change but the same is not happening for button's image view. Is it because of buttonType ? UIButton…
Sunil Rao
  • 800
  • 2
  • 6
  • 23
3
votes
2 answers

Left aligning image on centered UIButton

What is a good way to have the image edge insets of a UIButton be left aligned while having the title completely centered? Such as the following: The image would have a constant left inset, but the title would always be centered in the entire…
Daniel Larsson
  • 6,278
  • 5
  • 44
  • 82
3
votes
4 answers

Selector method of UIButton not called during animation

I have dynamically created buttons on a dynamic view and later I add that dynamic view to main view. Everything is working well except that the selector method of UIButton is not called. var baseView:UIView? override func viewDidLoad() { …
ankit
  • 3,537
  • 1
  • 16
  • 32
3
votes
2 answers

Aligning image on right side of title on UIButton with imageEdgeInsets and titleEdgeInsets

I would like to add an image on the right side of the title something like this |Button [image]| |title | And I am able to achieve this by this code button.titleEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0) button.imageEdgeInsets =…
Avim
  • 101
  • 1
  • 10
3
votes
2 answers

How to make the frame of a button custom shape in Swift 2

I want the button to be reactive to tap only in the custom polygonal shape that I create and not in the CGRect frame. button.frame only supports CGRect.
Fabio Laghi
  • 227
  • 1
  • 3
  • 6
3
votes
5 answers

UIButton | setTitle taking huge amount of time even in main thread

I’m reopening this question because my last one wast flagged as duplicate even if it’s actually not ! It’s the same problem but the solutions are not working with my code. I’m using swift 2. So my problem is, as the title says : I have a UIButton in…
Nicolas Meienberger
  • 777
  • 2
  • 8
  • 18
3
votes
2 answers

Customize UITextField Clear Button Color to White Color

I want to change Color of the UITextField's Clear Button, As I Know I can achieve the same with accessing the RightView Property of the TextField as Well as also I can use an Image to do the same. But No, I want to change the colour of that button…
Bhargav Kukadiya
  • 418
  • 7
  • 17
3
votes
1 answer

How is a UIButton's image set programmatically?

How does one set the image of a UIButton from within the code? I try the following but it just leaves the button as a white square. [A1 setImage:[UIImage imageNamed:[NSString stringWithFormat:@"m1.10001.png"]] forState:UIControlStateNormal];
some_id
  • 29,466
  • 62
  • 182
  • 304
3
votes
1 answer

button on contentOverlayView not responding

I cannot work this out - it should be simple. I have: ShowAVPlayer method AVPlayerItem *video = [[AVPlayerItem alloc] initWithURL:url]; AVQueuePlayer *queue = [[AVQueuePlayer alloc] initWithItems:@[video]]; video = [[AVPlayerItem alloc]…
3
votes
0 answers

swift ios keyboard extension - long press / press and hold

I need to know how to add long press (press and hold) function to ios custom keyboard extension so that i con show multiple keys to chose one from. expected design my project structure current code for keypress action - code can add the title of…
user2994762
  • 115
  • 1
  • 2
  • 10
3
votes
2 answers

UIButtons in specific zone of the screen make delay on Touch Down event

I'm creating a Custom Keyboard for iOS. I have 4 rows of keys, each key have two actions: Touch Down to highlight button, and Touch Up Inside to unhighlight the button in 0.4 seconds. But at the left edge of the screen there is a zone where Touch…
zangar777
  • 41
  • 2