uicontrolstate

Overriding isHighlighted still changes UIControlState - why?

我只是一个虾纸丫 提交于 2019-12-11 15:55:45
问题 In a UIControl , if I override isHighlighted to set a private _isHighlighted property, and then check the control's state to see if it contains .highlighted , the state still accurately reflects the change. See code below. My question is, how is this possible? I never call super.isHighlighted or manipulate the state property. state is an OptionSet that must have the .highlighted property inserted into the set, which, from what I can determine, does not, or should not, happen if I override the

Disabled buttons not changing image in

不打扰是莪最后的温柔 提交于 2019-12-11 11:09:38
问题 I have a button that pushes to a settings viewController . On that settings viewController I has a switch to invert all the colors on the original view, an inversion which I've done programmatically. I made inverted button images to replace the original images. When I return to the original view, I have viewWillAppear call the method to invert if the switch has been flipped. Everything changes accordingly except for two disabled buttons. The switch value is saved under the default settings so

Whats the use of UIControlState “application” of UIButton?

独自空忆成欢 提交于 2019-12-10 12:39:36
问题 I went through the apple doc too but it just states that its Additional control-state flags available for application use. Its just a getter method so when does it get set? 回答1: application and reserved are basically markers. That is more clear when looking at the objective-c documentation for them: disabled: UIControlStateDisabled = 1 << 1 application: UIControlStateApplication = 0x00FF0000 reserved: UIControlStateReserved = 0xFF000000 That means that the second least significant bit of a

UIButton - On touch change image

隐身守侯 提交于 2019-11-30 14:50:13
问题 When I touch the button at that time I want to change image & when i release the touch button image is as it is. I want to apply below code but it's not with my expectation. please give me any suggestion..... -(IBAction)actionEnter:(id)sender{ if ([sender isSelected]) { [sender setImage:[UIImage imageNamed:@"enter-hover.png"] forState:UIControlStateNormal]; [sender setSelected:NO]; } else { [sender setImage:[UIImage imageNamed:@"enter.png"] forState:UIControlStateSelected]; [sender

UIButton - On touch change image

走远了吗. 提交于 2019-11-30 11:32:39
When I touch the button at that time I want to change image & when i release the touch button image is as it is. I want to apply below code but it's not with my expectation. please give me any suggestion..... -(IBAction)actionEnter:(id)sender{ if ([sender isSelected]) { [sender setImage:[UIImage imageNamed:@"enter-hover.png"] forState:UIControlStateNormal]; [sender setSelected:NO]; } else { [sender setImage:[UIImage imageNamed:@"enter.png"] forState:UIControlStateSelected]; [sender setSelected:YES]; } taskinoor You can use UIControlStateHighlighted for this. [myButton setImage:[UIImage

How to set the alpha of an UIImage in SWIFT programmatically?

ⅰ亾dé卋堺 提交于 2019-11-29 22:17:41
I found a lot solutions here but not for Swift , and I know you can do this with a UIImageView, but in my case i need an programmatically set alpha transparent background image for an UIButton . Best would be an UIImage extension! let img = UIImage(named: "imageWithoutAlpha") var imgInsets = UIEdgeInsetsMake(0, 24, 0, 24) image = image!.resizableImageWithCapInsets(imgInsets) let myButton = UIButton(frame: CGRect(x: 50, y: 50, width: img!.size.width, height: img!.size.height)) myButton.setBackgroundImage(img, forState: UIControlState.Normal) myButton.contentEdgeInsets = UIEdgeInsetsMake(0, 20,

How to set the alpha of an UIImage in SWIFT programmatically?

若如初见. 提交于 2019-11-28 18:54:07
问题 I found a lot solutions here but not for Swift , and I know you can do this with a UIImageView, but in my case i need an programmatically set alpha transparent background image for an UIButton . Best would be an UIImage extension! let img = UIImage(named: "imageWithoutAlpha") var imgInsets = UIEdgeInsetsMake(0, 24, 0, 24) image = image!.resizableImageWithCapInsets(imgInsets) let myButton = UIButton(frame: CGRect(x: 50, y: 50, width: img!.size.width, height: img!.size.height)) myButton

is it possible to update UIButton title/text programmatically?

久未见 提交于 2019-11-28 04:02:05
I have a UIButton , that when pressed, brings up a new view where the user can change some settings. When the view is dismissed, I'd like to update the title/text of the UIButton to reflect the new state. I'm calling: [myButton setTitle: @"myTitle" forState: UIControlStateNormal]; [myButton setTitle: @"myTitle" forState: UIControlStateApplication]; [myButton setTitle: @"myTitle" forState: UIControlStateHighlighted]; [myButton setTitle: @"myTitle" forState: UIControlStateReserved]; [myButton setTitle: @"myTitle" forState: UIControlStateSelected]; [myButton setTitle: @"myTitle" forState:

is it possible to update UIButton title/text programmatically?

和自甴很熟 提交于 2019-11-27 05:15:56
问题 I have a UIButton , that when pressed, brings up a new view where the user can change some settings. When the view is dismissed, I'd like to update the title/text of the UIButton to reflect the new state. I'm calling: [myButton setTitle: @"myTitle" forState: UIControlStateNormal]; [myButton setTitle: @"myTitle" forState: UIControlStateApplication]; [myButton setTitle: @"myTitle" forState: UIControlStateHighlighted]; [myButton setTitle: @"myTitle" forState: UIControlStateReserved]; [myButton