SKTextureGradient 4.0.1

SKTextureGradient 4.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2018
SPMSupports SPM

Maintained by Maxim Bilan.



  • By
  • Maxim Bilan

SKTextureGradient

Version License Platform CocoaPods CocoaPods

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

alt tag

License

SKTextureGradient is available under the MIT license. See the LICENSE file for more info.