matvdg/Gradient-View
关于
一个 Swift 4 UIView 类,可在 storyboard 中渲染渐变并自定义颜色、方向、阴影、圆角半径等。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Gradient-View
A Swift 4 UIView class with a gradient customizable in the storyboard (colors, direction, shadows, cornerRadius...)
GradientView: UIView is a @IBDesignable class so that it's rendered in your storyboard, and all its properties are @IBInspectable so that you can customize your gradient view inside the storyboard in the Attributes inspector.
Quick install:
- Just drag this class into your project
- In your storyboard, select a UIView
- Go the the identity inspector and in the class field, type GradientView instead of UIView
- Play with the attributes inspector with real-times results!
- you can select two colors for the gradient
- and one color for the shadow
- you can choose the shadow position (x/y) and its blur
- the direction of the gradient (top left is 0,0 and bottom right is 1,1) from the start point to the end point
- the corner radius of your view
- you can animate the gradient to another one by calling the
animate(duration: TimeInterval, newTopColor: UIColor, newBottomColor: UIColor)method

Quick Note
This is only for editing UIViews. Although it will work on other classes (buttons, etc.), the text that comes with those will be behind the gradient color. For this reason, if you wish to add it to other classes (buttons), you will need to composite a label on top of it so that you can still see the text.
探索相关项目
加载中…