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
1 answer

CALayer in awakeFromNib vs drawRect

I'm very confused, why does the following code work if I add it to awakeFromNib or initWithFrame:, but doesn't work if I add it to drawRect: or call it directly? self.layer.cornerRadius = CGRectGetWidth(self.bounds) / 2.0f; self.layer.shadowColor =…
Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76
3
votes
5 answers

How to set UIButton font via appearance proxy in iOS 8?

I tried to set the font of UIButton via appearance proxy. But it doesn't seem to work. This is what I tried. UIButton.appearance().titleFont = UIFont(name: FONT_NAME_DEFAULT, size:20.0) UIButton.appearance().titleLabel?.font = UIFont(name:…
Hlung
  • 13,850
  • 6
  • 71
  • 90
3
votes
2 answers

how can i create a pulsating animation for UIButton iOS?

iam trying to create a pulsating animation for UIButton These are my codes so far ,but still am not able to do the exact animation shown in this link CSS pulsating button My code UIButton *button = [UIButton…
abhi bangalore
  • 101
  • 2
  • 10
3
votes
1 answer

How to change the background color of a UIButton when tapped in swift?

ViewController: UIViewController { @IBAction func like(sender: AnyObject) { like(backgroundColor!) = UIColor.greenColor() } } I want to chanage the color of UIbutton"like button" : White is the default "not tapped or unlike" green when…
JAMESMATHEO12
  • 55
  • 2
  • 4
3
votes
6 answers

Get an Int out of an UILabel Swift

I have the problem, to have a high amount of buttons which have a number as their label, so i thought i could take the label as an integer instead of creating an action for every button?! @IBAction func NumberInput(sender: UIButton) { var…
André Kuhlmann
  • 4,378
  • 3
  • 23
  • 42
3
votes
3 answers

How can i change background color of UIButton on click in UITableviewCell?

I have UITableviewCell and i placed 4 buttons in cell. When i click one button i need to change its background color to red. Soo right now i have written code for this and when i click one button then that button background color is not changing…
tarah john
  • 33
  • 4
3
votes
2 answers

iOS UINavigationController barHideOnTapGestureRecognizer and UIButton interference

I have developed an app that makes use of the iOS8 feature to show or hide the navigation bar on a tap of the view. However, the main view contains a UIButton which also act upon taps. The problem is that both 'objects' are receiving the tap and if…
Fittoburst
  • 2,215
  • 2
  • 21
  • 33
3
votes
3 answers

iOS UIButton near screen edge not respond to tap normally

As shown in below image, part in the red rectangle in buttons near the screen edge cannot respond to tap normally. I've heard some mechanism in iOS that can disable touched near the edge for user experience consideration. So how to disable this…
wyp
  • 869
  • 3
  • 11
  • 23
3
votes
3 answers

KIF cannot tap UIButton inside UITableViewCell if it's its UITableView's only one

I am having trouble automating tapping on an UIButton that is embedded inside a UITableViewCell if that cell is the table's only one. This is in the context of UI automation with KIF. Here my relavant call: [tester tapViewWithAccessibilityLabel:…
Drux
  • 11,992
  • 13
  • 66
  • 116
3
votes
1 answer

UIButton dashed underline in Objective c

Normal underline works but dotted undeline doesn't seems to work? UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(100, 10, 300, 300); NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc]…
Durga Vundavalli
  • 1,790
  • 22
  • 26
3
votes
2 answers

UIButton as UINavigationItem titleView

I'm trying to place a UIButton as the titleView for my UINavigationItem. This is my code but it doesn't work. The title is completely blank. override func viewDidLoad() { super.viewDidLoad() let titleButton = UIButton() …
Fenda
  • 1,385
  • 3
  • 14
  • 24
3
votes
1 answer

UIButton text and image

I have one UIButton. In that UIButton i have to show text and image. Image should be displayed after the text. Based on text i want to adjust the button frame. See the image. After the text "I am a Button", i want to add a image like arrow.…
vishnu
  • 715
  • 9
  • 20
3
votes
1 answer

SWRevealViewController rightRevealToggle not working with UIButton in storyboard

In my xcode project, I want a UIButton to open a right slide-out menu using SWRevealViewController but it isn't working. Any help? He's the code in my view didLoad for the UIButton: SWRevealViewController *revealViewController =…
3
votes
2 answers

How do I rotate an UIButton in Swift?

I used to rotate an image this way: self.image.transform = CGAffineTransformRotate(self.image.transform, CGFloat(M_PI)) But this code doesn't work for a button: let rotateAnimation = CABasicAnimation(keyPath:…
Cesare
  • 9,139
  • 16
  • 78
  • 130
3
votes
2 answers

UIButton as a subview in UILabel

I am trying to dynamically add a UIbutton as a subview to UIlable. But I am not able to click the button. It seems that the label doesn't allow the buttonTapped event to occur. Can somebody explain what exactly is happening here? and can anybody…
Jayshree
  • 281
  • 1
  • 6
  • 28