developer

Setting an image for a UIButton in code

Question: ❓❓❓ How do you set the image for a UIButton in code? I have this: UIButton *btnTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btnTwo.frame = CGRectMake(40, 140, 240, 30); [btnTwo setTitle:@"vc2:v1" forState:UIControlStateNormal]; [btnTwo addTarget:self action:@selector(goToOne) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btnTwo]; but don’t see what will set the image for it. Good Answer: 👌👌👌 Objective-C Read more…

By admin, ago
developer

Color Tint UIButton Image

Question: ❓❓❓ I noticed that when I place a white or black UIImage into a UISegmentedControl it automatically color masks it to match the tint of the segmented control. I thought this was really cool, and was wondering if I could do this elsewhere as well. For example, I have Read more…

By admin, ago
developer

UIButton remove all target-actions

Question: ❓❓❓ I have added multiple target-action-forControlEvents: to a UIButton. I’d like to remove all of these in one go without deallocating anything. I will then set new targets. Is this possible and how do I go about it? Good Answer: 👌👌👌 Call removeTarget:action:forControlEvents:, pass nil for the target, NULL Read more…

By admin, ago
developer

How do you add multi-line text to a UIButton?

Question: ❓❓❓ I have the following code… UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds]; buttonLabel.text = @"Long text string"; [targetButton addSubview:buttonLabel]; [targetButton bringSubviewToFront:buttonLabel]; …the idea being that I can have multi-line text for the button, but the text is always obscured by the backgroundImage of the UIButton. A logging call to Read more…

By admin, ago
developer

Set UIButton title UILabel font size programmatically

Question: ❓❓❓ I need to set the font size of the title UILabel of a UIButton programmatically. Good Answer: 👌👌👌 button.titleLabel.font = [UIFont systemFontOfSize:size]; should help Read More: 👉 https://stackoverflow.com/questions/1465305/set-uibutton-title-uilabel-font-size-programmatically

By admin, ago