SKTextureGradient
一个用于在 SpriteKit 中创建渐变效果的简单 SKTexture 扩展。
安装
CocoaPods
pod 'SKTextureGradient'
手动
Copy SKTextureGradient.swift to your project.
使用
let topColor = CIColor(rgba: "#71B280") let bottomColor = CIColor(rgba: "#134E5E") let texture = SKTexture(size: CGSizeMake(200, 200), color1: topColor, color2: bottomColor, direction: GradientDirection.up) texture.filteringMode = .Nearest let sprite = SKSpriteNode(texture: texture) sprite.position = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame)) sprite.size = self.frame.size addChild(sprite)
示例
许可证
SKTextureGradient 基于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。