How to change the highlighted color of a UIButton? [duplicate]

Try to Override the UIButton with the following Method.. and just change the backgroud color of button when its in highlighted state. – (void)setHighlighted:(BOOL)highlighted { [super setHighlighted:highlighted]; if (highlighted) { self.backgroundColor = [UIColor Your Customcolor]; } else{ self.backgroundColor = [UIColor Your DefaultColor]; } } Try it..hope it helps

UIButton that resizes to fit its titleLabel

Swift 4.x version of Kubba’s answer: Need to Update Line Break as Clip/WordWrap/ in Interface builder to corresponding buttons. class ResizableButton: UIButton { override var intrinsicContentSize: CGSize { let labelSize = titleLabel?.sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude)) ?? .zero let desiredButtonSize = CGSize(width: labelSize.width + titleEdgeInsets.left + titleEdgeInsets.right, height: labelSize.height + titleEdgeInsets.top + titleEdgeInsets.bottom) return desiredButtonSize } … Read more

UIButton with IB_DESIGNABLE throws runtime attribute warning and does not render in Interface Builder

I have been working extensively with Live Views since it’s introductions and like a lot of new features in Xcode initially, it has some flaws. Still I like it a lot and I hope that it will be improved in newer versions. Cause: Live Views work with @property properties that get a special IB_Designable tag … Read more

detecting uibutton pressed in tableview: Swift Best Practices

If your code allows, I’d recommend you set the UIButton tag equal to the indexPath.row, so when its action is triggered, you can pull the tag and thus row out of the button data during the triggered method. For example, in cellForRowAtIndexPath you can set the tag: button.tag = indexPath.row button.addTarget(self, action: “buttonClicked:”, forControlEvents: UIControlEvents.TouchUpInside) … Read more

UIButton label text is being clipped

You should use setTitle:forState: to change the title of a UIButton. If you change the title yourself, the button has no indication that it needs to resize the label – you’d end up having to do something like this: myButton.titleLabel.text = @”this is the new label”; [myButton setNeedsLayout]; but I’m not even sure that would work … Read more

How to add only a TOP border on a UIButton?

UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, btn.frame.size.width, 1)]; lineView.backgroundColor = [UIColor redColor]; [btn addSubview:lineView]; you can do the same for each border. Adding multiple UIViews you can add bottom and left or top and right or any border you want. i.e. bottom & left: UIView *bottomBorder = [[UIView alloc] initWithFrame:CGRectMake(0, btn.frame.size.height – 1.0f, btn.frame.size.width, … Read more

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