Manually drawing a gradient in iPhone apps?

后端 未结 7 1472
一个人的身影
一个人的身影 2020-12-28 20:53

If I have two UIColors, what\'s the best way to draw an even gradient between them over an arbitrarily-sized area?

I am guessing you would create a UIView subclass a

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 21:21

    For views that draw text, such as UILabel, UITextView, and UITextField, you should add the gradient inside the drawRect function. (see this post for an example).

    There are some great subclasses of UILabel, UITextView, and UITextField that allow you to add a gradient pretty easily (see JBGradient on GitHub).

提交回复
热议问题