14

Solution note, not a question.

I used this code to set background as a pattern image:

UIImage *bg     =   SomeImage();
UIColor *bgc    =   [UIColor colorWithPatternImage:bg];
[self setBackgroundColor:bgc];
[self setOpaque:NO];

This works, but alpha blending doesn't work. Might be a bug. How to make it work?

  • Platform: iOS SDK 4.1
Community
  • 1
  • 1
eonil
  • 83,476
  • 81
  • 317
  • 516
  • 2
    Ahh, you genius! I'm so glad you posted this Eonil. Saved me hours of head scratching and eye gouging. Might be worth mentioning: to access and modify layer properties one'll need to import ``. – David Foster Oct 17 '10 at 11:31

1 Answers1

12

This code make it alpha blended on both of simulator and device.

UIImage *bg     =   SomeImage();
UIColor *bgc    =   [UIColor colorWithPatternImage:bg];
[self setBackgroundColor:bgc];
[self setOpaque:NO];
[[self layer] setOpaque:NO];      // Added this line.
eonil
  • 83,476
  • 81
  • 317
  • 516