Reputation: 65
I'm trying to set an image as a background instead of a color. Here's the code I'm using right now:
[testing setBackgroundColor:color];
[testing setFont: [UIFont fontWithName:@"Helvetica" size:33]];
Is there another [testing set] object to set the background as an image instead of a color? I don't think this is right:
[testing setImage:[UIImage imageNamed:@"test.png"] forState:UIControlStateNormal];
Thanks!
Upvotes: 0
Views: 151
Reputation: 1083
try
testing.backgroundColor =
[UIColor colorWithPatternImage:[UIImage imageNamed:@"test.png"]];
another possible solution would be making a UIImageView in your nib/storyboard set the image in the attribute inspector and send to back in Editor > Arrange > send to back
Upvotes: 0
Reputation: 6844
You could use the following:
[testing setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"test.png"]]];
Personally, I would recommend using a UIImageView instead.
Please note that using colorWithPatternImage will repeat the image to fill the view.
Upvotes: 1