Here is the solution. (Note: I am using Rubymotion, ruby โโbinding for Objective C / iOS, however the logic is exactly the same. If someone wants to edit this and put an objective c-equivalent, continue
size = CGSizeMake(50,50) scale = options[:scale] || UIScreen.mainScreen.scale opaque = options.fetch(:opaque, false) UIGraphicsBeginImageContextWithOptions(size, opaque, scale) context = UIGraphicsGetCurrentContext() gradient = CAGradientLayer.layer gradient.frame = CGRectMake(0,0,50,50) gradient.colors = [SKColor.blackColor.CGColor,SKColor.whiteColor.CGColor] gradient.renderInContext(context) image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() texture = SKTexture.textureWithCGImage(image.CGImage) node = SKSpriteNode.alloc.initWithTexture(texture)
AwDogsGo2Heaven
source share