开发者

Custom Button not showing my images for pushed state

开发者 https://www.devze.com 2023-02-19 00:51 出处:网络
In code, I set the following: btnLogo.SetImage(UIImage.FromBundle(\"images/Zouak_logo_button.png\"), UIControlState.Normal);

In code, I set the following: btnLogo.SetImage(UIImage.FromBundle("images/Zouak_logo_button.png"), UIControlState.Normal); btnLogo.SetImage(UIImage.FromBundle("images/Zouak_logo_button_pushed.png"), UIControlState.Selected);

I couldn't find a UIControlState.Pressed or Pushed or anything along those lines. When the butto开发者_Go百科n is pushed of course it isn't showing the version of the image that I want. Do I need to do this in the Click event manually?


I think your syntax is kind of strange, but I guess that you want to do:

UIButton *btn = [[UIButton alloc] init];
[btn setImage:uiimg forState:UIControlStateHighlighted];


Do this for all states:

UIImage *newNormalImage = [UIImage imageNamed:@"images/Zouak_logo_button.png"];
[btnLogo setBackgroundImage:newNormalImage forState:UIControlStateNormal];
// Image for highlighted state
UIImage *newHighlightedImage = [UIImage imageNamed:@"mages/Zouak_logo_button_pushed.png"];
[btnLogo setBackgroundImage:newHighlightedImage forState:UIControlStateHighlighted];
// Image for selected state
UIImage *newSelectedImage = [UIImage imageNamed:@"mages/Zouak_logo_button_pushed.png"];
[btnLogo setBackgroundImage:newSelectedImage forState:UIControlStateSelected];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号