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 3 Check which segue was used

I have created a game where at first a home screen is presented to the user. If the user selects play game the buttons and background disappear and the game begins in the form of an SKScene. Then when the player dies there is an automatic segue to a…
3
votes
1 answer

add action to programmatically created uibuttons

I have written a class file to create a topBar for my app, I also add in buttons to the top bar after adding target to the buttons added, the same is not triggered the line menuButton.addTarget(self, action: #selector(showMenu), for:…
melwyn pawar
  • 1,766
  • 2
  • 16
  • 21
3
votes
0 answers

How to prevent my custom UIControl to pass touch event through underlying view

I create a custom UIControl, but when I tap on my control, touch event always passing through to superview. Here is my set up and sample project for this https://dl.dropboxusercontent.com/u/2271974/FunWithUIControl.zip View with tap gesture -…
sarunw
  • 8,036
  • 11
  • 48
  • 84
3
votes
2 answers

Corner radius for UIButton not working after upgrading to Xcode 8

I am setting the corner radius of UIButton as follows: self.btnFBLogin.layer.cornerRadius = self.btnFBLogin.frame.size.height/2; self.btnFBLogin.layer.masksToBounds = YES; However, after upgrading to Xcode 8 it is not working. Button is not…
Sujit Dalai
  • 43
  • 1
  • 5
3
votes
2 answers

Swift: UIButton touch event not getting called inside the custom view

I have created a custom view from xib(freeform) in which there are two button (Login and cancel) and i have present it at a view according to some condition. Custom view get present on another view nicely but the button(Login an cancel) not getting…
3
votes
2 answers

What is the best way to reuse the attributes from a UIButton in Swift

I have a bunch of buttons that I'm adding to a UIToolbar when a UITextField is tapped using inputAccessoryView. All of these buttons are identical except for the title and what I would like to be able to do is reuse the UI attributes such as…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
3
votes
2 answers

Button frame change at runtime

I have a subclass of UIButton: class ColorButton: UIButton { override func awakeFromNib() { self.layer.backgroundColor = UIColor.blackColor().CGColor self.layer.cornerRadius = frame.size.width / 2 self.clipsToBounds =…
3
votes
2 answers

Button to reload UIWebView

I have created a button over top of a UIWebView that I would like to use to refresh the webview when pressed. The following code is in my ViewController class: @IBOutlet weak var webView: UIWebView! override func shouldAutorotate() -> Bool { …
atwalsh
  • 3,622
  • 1
  • 19
  • 38
3
votes
1 answer

UIButton not responding to touches

I've the following view: The way it is build up UIViewController --> UIView (bottom square) --> UIViewController (is loaded in the bottom square) Button presses within in this UIViewController are not being triggered. However I do see the button…
Rutger Huijsmans
  • 2,330
  • 2
  • 30
  • 67
3
votes
1 answer

Rounding only left side of UIButton without removing uieffect

I have two uibuttons that a right next to eachother. I would like to make them look joined by giving the left button rounded top left and bottom left corners and the right button top right and bottom right corners. I have seen several solutions to…
3
votes
1 answer

Make Button NOT change title color when pressed

I can't find any other question on how to prevent this, and nothing I've tried is working perfectly. I want to make it so the title color of the text on my button is ALWAYS white (I will do some other styling to make this look good still). But,…
Michael Yaworski
  • 13,410
  • 19
  • 69
  • 97
3
votes
1 answer

UIButton not working on a subview of UIWindow

I'm trying to create a custom one-button AlertViewController in Swift, I use window.addSubview() to show the AlertView, but when touch the button on the AlertView, the func buttonTapped() is not working, below is my code, please tell me what's wrong…
Keater
  • 123
  • 2
  • 9
3
votes
2 answers

How do I get the values from Custom UITableViewCell to ViewController?

I have two UITextFields on the UITableViewCell and their IBOutlets are connected in the custom UITableViewCell class called as "CustomCell.swift". The Enter button is there on the UIView of ViewController and its IBAction is there in the…
Anirudha Mahale
  • 2,526
  • 3
  • 37
  • 57
3
votes
1 answer

Swift. Changing multiple UIButtons with IBOutlet

So, I have 20 UI buttons on a single viewcontroller. I also have 2 other buttons there that will change the currentTitle or background color of different groups of those buttons. (for example, pressing one of those 2 buttons will change the color of…
3
votes
1 answer

Swift: UIButton within a custom UITableViewCell 'Unrecognised selector sent to instance' error

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cellIdentifier = "ExerciseMenuCell" let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)…
Ryan Hampton
  • 319
  • 1
  • 4
  • 21