2

I have a UIButton(Button place at bottom) setting the properties via storyboard. While tap on the button not showing the Highlighted image of the button but, button Click is working, Other buttons in the screen showing the Highlighted image. Edit: The button is place on bottom of the screen, My screen size is 320x568, - I have placed three buttons with Y value 515, that is not working. (button width- 75, height - 37) Also tried to change the button position then, it is working fine.

I am using Xcode 7.1.1

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130

3 Answers3

0

Try the below code.It will help you.

[Button setImage:[UIImage imageNamed:@"your image.png"] forState:UIControlStateHighlighted];
user3182143
  • 9,459
  • 3
  • 32
  • 39
0
-(IBAction)YourButtonClick:(id)sender
{
    UIButton *btn = (UIButton *)sender;
    [btn setImage:[UIImage imageNamed:@"your image.png"] forState:UIControlStateHighlighted];
    [btn setImage:[UIImage imageNamed:@"your image.png"] forState:UIControlStateSelected];
}
Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42
0

I've faced with similar issue. What I did is setting appropriate image for each state

-(void)setupMediaPlusButtonImagesForStates {

    [self.mediaPlusButton setImage:[UIImage imageNamed:@"details_plus_icon"] forState:UIControlStateNormal];

    [self.mediaPlusButton setImage:[UIImage imageNamed:@"details_plus_highlighted_icon"] forState:(UIControlStateNormal | UIControlStateHighlighted)];    

    [self.mediaPlusButton setImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateSelected];    

    [self.mediaPlusButton setImage:[UIImage imageNamed:@"close_button_highlighted.png"] forState:(UIControlStateHighlighted | UIControlStateSelected)];    
}
O.G.O
  • 149
  • 1
  • 9