How can I create a UILabel
with a background image and adjust the t开发者_运维百科ransparency (alpha channel) of the background image without changing the transparency of the text?
If there's no easy way to accomplish this within the UILabel
object by itself, what about creating a custom UIView
object that's composed of a UIImageView
and a UILabel
, which would allow me to adjust the alpha channel of the image independently of the UILabel
's alpha channel? Is that more complicated than it needs to be?
Thanks so much for your wisdom!
A Google codesearch for UIImage, alpha and CGImageRef doesn't turn anything that does exactly what you need, but lots of related code (see for example this). The way I would do follows the same pattern, getting a CGImageRef from your image, drawing it with a composition mode with your transparency, and getting back a UIImage from that using [UIImage imageWithCGImage:]
.
精彩评论