iOS Buttons – add border

Try this for adding border, It will work #import <QuartzCore/QuartzCore.h> then in viewDidLoad _btn.layer.borderWidth=1.0f; _btn.layer.borderColor=[[UIColor blackColor] CGColor]; _btn.layer.cornerRadius = 10; also you can fill the color for making appearance somewhat like button, or best way is to use image there Apart from BorderColor, you can do it by using Runtime attributes too.

How do I set UIButton background color forState: UIControlState.Highlighted in Swift

If anyone stops by, another way to go maybe more easily if it is something you need more than once… I wrote a short extension for UIButton, it works just fine: for Swift 3 extension UIButton { func setBackgroundColor(color: UIColor, forState: UIControlState) { UIGraphicsBeginImageContext(CGSize(width: 1, height: 1)) CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), color.CGColor) CGContextFillRect(UIGraphicsGetCurrentContext(), CGRect(x: 0, y: 0, width: … Read more

UIButton touch is delayed when in UIScrollView

Jeff’s solution wasn’t quite working for me, but this similar one does: http://charlesharley.com/2013/programming/uibutton-in-uitableviewcell-has-no-highlight-state In addition to overriding touchesShouldCancelInContentView in your scroll view subclass, you still need to set delaysContentTouches to false. Lastly, you need to return true rather than false for your buttons. Here’s a modified example from the above link. As commenters suggested, it … Read more

How to change the tint color of the clear button on a UITextField

Here you go! A TintTextField. Using no custom image, or added buttons etc. class TintTextField: UITextField { var tintedClearImage: UIImage? required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.setupTintColor() } override init(frame: CGRect) { super.init(frame: frame) self.setupTintColor() } func setupTintColor() { self.borderStyle = UITextField.BorderStyle.roundedRect self.layer.cornerRadius = 8.0 self.layer.masksToBounds = true self.layer.borderColor = self.tintColor.cgColor self.layer.borderWidth = 1.5 … Read more

What is the difference between Highlighted and Selected UIButton’s State?

The answers from 2012 aren’t incorrect, but some might find the explanation in the UIControl docs to be…anemic. I personally find this explanation from the Collection View Programming Guide for iOS to be more helpful: There is a subtle but important distinction between a cell’s highlighted state and its selected state. The highlighted state is … Read more

How to create a circular button in Swift? [closed]

Here is an example round button: Swift 3, 4, 5: override func viewDidLoad() { super.viewDidLoad() let button = UIButton(type: .custom) button.frame = CGRect(x: 160, y: 100, width: 50, height: 50) button.layer.cornerRadius = 0.5 * button.bounds.size.width button.clipsToBounds = true button.setImage(UIImage(named:”thumbsUp.png”), for: .normal) button.addTarget(self, action: #selector(thumbsUpButtonPressed), for: .touchUpInside) view.addSubview(button) } @objc func thumbsUpButtonPressed() { print(“thumbs up button … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)