用 ThemeSwift 库替换渐变颜色(用于应用程序主题管理的库)
如何使用这个库来实现渐变颜色,因为他们在文档中没有提到 ThemeAnyPicker 中渐变的使用。
我正在使用 plist 方法,这比另一种方法更简单。 (该库可以通过两种方式使用:Index 方法和 Plist 方法)
主题库链接:https://github。 com/wxxsw/SwiftTheme
我给出了下面的代码。
@IBDesignable class GradientView: UIView {
override class var layerClass: AnyClass {
return CAGradientLayer.self
}
override func layoutSubviews() {
// MARK: - Default gradient (Without applying Swift theme library)
(layer as! CAGradientLayer).colors = [topColor.cgColor, bottomColor.cgColor]
// MARK: - With Swift Theme library applied
(layer as! CAGradientLayer).theme_colors = // What should be the code here?
}
}
How to use this library for gradient colors as they haven't mentioned the usage of gradient with ThemeAnyPicker in their documentation.
I am using plist method which is much easier way than the other one. (This library can be used in 2 ways : Index method and Plist method)
Theme library link : https://github.com/wxxsw/SwiftTheme
I have given the code below.
@IBDesignable class GradientView: UIView {
override class var layerClass: AnyClass {
return CAGradientLayer.self
}
override func layoutSubviews() {
// MARK: - Default gradient (Without applying Swift theme library)
(layer as! CAGradientLayer).colors = [topColor.cgColor, bottomColor.cgColor]
// MARK: - With Swift Theme library applied
(layer as! CAGradientLayer).theme_colors = // What should be the code here?
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
监听颜色变化并在回调中重置绘图的颜色
Listen for color changes and reset the color of the drawing in the callback