Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy does initWithPatternImage loses the alpha values of the PNG
    primarykey
    data
    text
    <p>Anyone ever seen the problem of [UIColor initWithPatternImage] ignoring the alpha values of the PNG? If so, what's the best fix?</p> <p>I am using a png as a background layer to my array of button objects and it contains several pre-set alpha values per pixel in the image that is to be used as a texture background. It loads fine as a pattern/texture-color, but it comes up with all key transparent area as opaque black.</p> <p>It is important that I get the right alpha values so that the button images shows correctly. The button frames do not include the alpha shadows from the background as that is not the "clickable" portion of the button. Additionally, my button object's images and background images also makes use of transparency, so it really needs to have a clear background directly behind each button to let the proper true current color settings come through (lowest layer UIView will have its background color set to the current user's selected color). Setting just the single alpha value for the UIView layer containing this texture does not work for my needs either.</p> <p>Any help would be appreciated. My current workaround would be to use fully-blown, repeatedly-programmed layout of several UIImageView using the png, instead of a single UIView with the pattern fill.</p> <p>Here is a snippet of code, but it's pretty standard for turning a UIImage into a UIColor for use as a pattern/texture color:</p> <pre><code> UIView *selectorView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,320)]; UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"SelectorViewBackground.png"]]; selectorView.backgroundColor = background; [mainView addSubview:selectorView]; // pattern background layer. Add UIButtons on top of this selectorView layer [self addSubview:mainView]; // current user selected color set in mainView. [selectorView release]; [background release]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload