小编Lav*_*azh的帖子

分段控制中的渐变色调

我用这种方法得到渐变图像

func gradient(size:CGSize,color:[UIColor]) -> UIImage?{
    //turn color into cgcolor
    let colors = color.map{$0.cgColor}
    //begin graphics context
    UIGraphicsBeginImageContextWithOptions(size, true, 0.0)
    guard let context = UIGraphicsGetCurrentContext() else {
        return nil
    }
    // From now on, the context gets ended if any return happens
    defer {UIGraphicsEndImageContext()}
    //create core graphics context
    let locations:[CGFloat] = [0.0,1.0]
    guard let gredient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: colors as NSArray as CFArray, locations: locations) else {
        return nil
    }
    //draw the gradient
    context.drawLinearGradient(gredient, start: CGPoint(x:0.0,y:size.height), end: CGPoint(x:size.width,y:size.height), options: []) …
Run Code Online (Sandbox Code Playgroud)

gradient uikit ios swift segmentedcontrol

6
推荐指数
1
解决办法
2155
查看次数

如何在ARKit中制作自然采光?

我希望在我的ARKit项目中添加项目的照明类似于真实世界的对象.请解释一下如何实现这个目标?谢谢

lighting ios scenekit swift arkit

0
推荐指数
1
解决办法
1843
查看次数

标签 统计

ios ×2

swift ×2

arkit ×1

gradient ×1

lighting ×1

scenekit ×1

segmentedcontrol ×1

uikit ×1