我在swift中进行元数据实现并遇到了一些问题。目前我无法对屏幕进行径向渐变绘制,这是我目前尝试制作径向渐变。
import SpriteKit
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
var context = UIGraphicsGetCurrentContext()
var colorspace = CGColorSpaceCreateDeviceRGB()
var colors : [CGColor] = [UIColor.redColor().CGColor, UIColor.greenColor().CGColor, UIColor.blueColor().CGColor, UIColor.yellowColor().CGColor]
var locations :[CGFloat] = [ 0.0, 0.25, 0.5, 0.75 ]
var gradient = CGGradientCreateWithColors(colorspace, colors, locations)
CGContextDrawRadialGradient(context, gradient, CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)), CGFloat(20), CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)), CGFloat(30), CGGradientDrawingOptions(kCGGradientDrawsAfterEndLocation))
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
}
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
}
非常感谢任何帮助