How to remove UIButton selected background color?
I had this same issue and I resolve it by changing the UIButton type from “System” to “Custom”. The blue background color does not show up in selected state when it is a “Custom” type.
I had this same issue and I resolve it by changing the UIButton type from “System” to “Custom”. The blue background color does not show up in selected state when it is a “Custom” type.
The Cocoa frameworks take the approach that the Object Composition pattern is more appropriate than traditional class hierarchy. In general, this means that there is likely to be a property on UIButton where you can set another object to handle various aspects of the button. This is the preferred way to “customize” how your button … Read more
If doing this in iOS 9 or later, you should use the Contacts framework: @import Contacts; You also need to update your Info.plist, adding a NSContactsUsageDescription to explain why your app requires access to contacts. Then, when you then want to programmatically add the contact, then you can do something like: CNAuthorizationStatus status = [CNContactStore … Read more
The documentation is pretty clear on this. -sizeToFit pretty much calls -sizeThatFits: (probably with the view’s current size as the argument), and the default implementation of -sizeThatFits: does almost nothing (it just returns its argument). Some UIView subclasses override -sizeThatFits: to do something more useful (e.g. UILabel). If you want any other functionality (such as … Read more
New iOS 13 support SF Symbols now UIImage(systemName: “trash”) for swift 4.2 (call it on main thread) extension UIBarButtonItem.SystemItem { func image() -> UIImage? { let tempItem = UIBarButtonItem(barButtonSystemItem: self, target: nil, action: nil) // add to toolbar and render it let bar = UIToolbar() bar.setItems([tempItem], animated: false) bar.snapshotView(afterScreenUpdates: true) // got image from real … Read more
To fire an event programmatically you need to call sendActionsForControlEvent button.sendActionsForControlEvents(.TouchUpInside) — Swift 3 button.sendActions(for: .touchUpInside)
I had the same problem where I wanted my button to grow along with its title. I had to sublcass the UIButton and its intrinsicContentSize so that it returns the intrinsic size of the label. – (CGSize)intrinsicContentSize { return self.titleLabel.intrinsicContentSize; } Since the UILabel is multiline, its intrinsicContentSize is unknown and you have to set … Read more
You might want to be more specific next time you ask a question. You can try assign a different tag for each button in interface builder (or the same tag if thats what you need) and then use the following code for (int i = 1 ; i<=10;i++) { UIButton *myButton = (UIButton *)[myView viewWithTag:i]; … Read more
You need to use setTitle:forState: method instead of setting the titleLabel.text property: [startButton setTitle:@”Start” forState:UIControlStateNormal]; // Normal and highlighted titles do not need to be the same [startButton setTitle:@”Start!” forState:UIControlStateHighlighted]; What happens now is that you set the title in the label that represents the view of the current state, but once the state changes … Read more
self.mybutton.titleLabel.minimumScaleFactor = 0.5f; self.mybutton.titleLabel.numberOfLines = 0; <– Or to desired number of lines self.mybutton.titleLabel.adjustsFontSizeToFitWidth = YES; … did the trick, after layoutIfNeeded in viewDidLoad As it turns out, all those must be set to actually adjust the font-size, not just making it fit into the frame. Update for Swift 3: mybutton.titleLabel?.minimumScaleFactor = 0.5 mybutton.titleLabel?.numberOfLines = … Read more