使用colorWithPatternImage时如何保持图像透明度: [英] How to preserve image transparency when using colorWithPatternImage:

查看:102
本文介绍了使用colorWithPatternImage时如何保持图像透明度:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张透明的图片,如下所示:

I have an image prepared with transparency, like this:

使用两个UI视图,我将背景颜色配置为:

With two UIviews, I configure the background colors as so:

self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
self.dashedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"red_square.png"]];

我希望红色正方形在UIView上重复保留透明度,但它已由一个填充像这样的纯色:

I expect the red square to be repeated over the UIView with transparency preserved, but it's been filled by a solid color like this:

我不明白为什么。是否有一种简单的方法来绘制具有透明度的平铺图像?或者我是否需要查看绘制核心图形模式?

I don't understand why. Is there a simple way to draw a tiled image with transparency? Or do I need to look at drawing Core Graphics patterns?

推荐答案

模式图像应保持透明度正常。

Pattern images should be keeping the transparency just fine.

尝试 [self.dashedView setOpaque:NO]

这篇关于使用colorWithPatternImage时如何保持图像透明度:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆