How to apply a tintColor to a UIImage?

If you are just supporting iOS 7 you can use tintColor and UIImageRenderingModeAlwaysTemplate This article covers that: https://www.captechconsulting.com/blogs/ios-7-tutorial-series-tint-color-and-easy-app-theming If you need to support an earlier version you may want to consider this thread How would I tint an image programmatically on the iPhone?

UIButton block equivalent to addTarget:action:forControlEvents: method?

I just implemented this. It work’s like a charm! And it wasn’t even hard. typedef void (^ActionBlock)(); @interface UIBlockButton : UIButton { ActionBlock _actionBlock; } -(void) handleControlEvent:(UIControlEvents)event withBlock:(ActionBlock) action; @end @implementation UIBlockButton -(void) handleControlEvent:(UIControlEvents)event withBlock:(ActionBlock) action { _actionBlock = action; [self addTarget:self action:@selector(callActionBlock:) forControlEvents:event]; } -(void) callActionBlock:(id)sender{ _actionBlock(); } @end

iOS NSAttributedString on UIButton

It looks to me like you forgot in your code to use the “style” object that you set up.. you just instantiated it. You should modify your code to look like this: NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [style setAlignment:NSTextAlignmentCenter]; [style setLineBreakMode:NSLineBreakByWordWrapping]; UIFont *font1 = [UIFont fontWithName:@”HelveticaNeue-Medium” size:20.0f]; UIFont *font2 = [UIFont fontWithName:@”HelveticaNeue-Light” size:20.0f]; NSDictionary … Read more

Change a UIButton’s text (padding) programmatically in Swift

Still valid for: iOS 12/Xcode 10/Swift 4.2/OSX 10.13.2 iOS 9.1/Xcode 7.1/Swift 2.1/OSX 10.10.5: The method titleEdgeInsets didn’t work for me. My button’s frame tightly hugs the text (I didn’t specify a frame size), and the frame has a red background color. After doing: myButton.titleEdgeInsets = UIEdgeInsetsMake(10,10,10,10) the red background shrunk inwards by 10 pixels on … Read more

Adding a closure as target to a UIButton

With iOS 14 Apple has finally added this feature to UIKit. However, someone might still want to use this extension because Apple’s method signature is suboptimal. iOS 14: extension UIControl { func addAction(for controlEvents: UIControl.Event = .touchUpInside, _ closure: @escaping()->()) { addAction(UIAction { (action: UIAction) in closure() }, for: controlEvents) } } pre-iOS 14: extension … Read more

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