SKTextureGradient
A simple SKTexture extension for creating a gradient effect in SpriteKit.
Installation
CocoaPods:
pod 'SKTextureGradient'
Manual:
Copy SKTextureGradient.swift to your project.
Using
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)
Example
License
SKTextureGradient is available under the MIT license. See the LICENSE file for more info.