在代码中,我设置了以下内容: btnLogo.SetImage(UIImage.FromBundle(“images / Zouak_logo_button.png”),UIControlState.Normal); btnLogo.SetImage(UIImage.FromBundle(“images / Zouak_logo_button_pushed.png”),UIControlState.Selected);
我无法找到UIControlState.Pressed或Pushed或其他任何内容。当按下按钮时,它没有显示我想要的图像版本。我是否需要手动在Click事件中执行此操作?
答案 0 :(得分:1)
我认为你的语法有点奇怪,但我猜你想这样做:
UIButton *btn = [[UIButton alloc] init];
[btn setImage:uiimg forState:UIControlStateHighlighted];
答案 1 :(得分:1)
为所有州执行此操作:
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];