Get pixel color in sceneKit View, iOS, Swift

I try to get the color of a specific pixel in my sceneKit view. However, I only get the color of my background. In my scene I have a sphere with an image on the texture. Can somebody help me?

import UIKit

extension UIView {
    func getColourFromPoint(point:CGPoint) -> UIColor {
        let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()!
        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)

    var pixelData:[UInt8] = [0, 0, 0, 0]

    let context = CGBitmapContextCreate(&pixelData, 1, 1, 8, 4, colorSpace, bitmapInfo.rawValue)

    CGContextTranslateCTM(context, -point.x, -point.y);

    let red:CGFloat = CGFloat(pixelData[0])/CGFloat(255.0)
    let green:CGFloat = CGFloat(pixelData[1])/CGFloat(255.0)
    let blue:CGFloat = CGFloat(pixelData[2])/CGFloat(255.0)
    let alpha:CGFloat = CGFloat(pixelData[3])/CGFloat(255.0)

    let color:UIColor = UIColor(red: red, green: green, blue: blue, alpha: alpha)
        print(red, green, blue, alpha)
        return color

  • I want to force keyboard on with bluetooth device
  • Android & iOS: How to develop for both?
  • iOS and multiple OpenGL views
  • Keep object alive until a background task finishes
  • sending a post from iOS app to php script not working… Simple solution is likey
  • Is IBOutletCollection guaranteed to be of correct order?