开发者

Fade out image but not text on UILabel for iPhone

I have a label I have added a background to like this:

myLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"some image"]];

The user will enter text into the label and when finished, I would like to have the background image fade away but have the text remain. I've tried UIView Animations 开发者_开发知识库but UIImage does not inherit from UIView so that method has not worked and I am a bit stuck. Either I need to add a background image to my label differently or animate in a different way to get the fade out. Any thoughts would be appreciated.


Why not just use a UIView where you add both another UIView with your background, and a UILabel on top, like so?

UIView

  • UIView
  • UILabel (with [UIColor clearColor] as backgroundColor)

Then you can fade out the second UIView, and the UILabel will remain visible.as backgroundColor)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜