Reputation: 69
I have an ImageView with a picture and a button centered within it. On the button I have a different UIImage and the background on the button is white. In Attributes Inspector I have selected the UIImage for the button and made the button custom but still I have white background on the button.
I want the background on the button to be the same as the picture on the ImageView. I thought it was enough to change the button to custom. I am using Xcode 5.0.2, is there anyone that could help me with this. This is what my ImageView + button looks like now:
And these are the settings for the button:
Upvotes: 0
Views: 121
Reputation: 19024
The following should do:
yourButton.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"yourImage"]]
Upvotes: 0
Reputation: 572
Add image that you use for ImageView to Background properties of your button.
Upvotes: 1
Reputation: 4279
If you're asking how to make background for the button clear, from within the Attributes Inspector scroll down to the View section and change the background to Clear Color
from the dropdown menu.
Also make sure your .png has a transparent background. If you've already set the background to Clear Color the issue could simply be that your .png has a white background rather than a clear one.
Upvotes: 1
Reputation: 403
try
[button setBackgroundImage:[UIImage imageNamed:@"name" forState:UIControlStateNormal]
Upvotes: 1