1

Because zoomed-in scroll view’s content was fuzzy, I implemented CATiledLayer as this article recommends. I made basic implementation like here I found.

Edges become more smooth, but when I moving views with UIPanGestureRecognizer, content starts flashing. Any idea how to fix?

How can I trigger to redraw layer, but without let it flashing? I guess neither v.setNeedsDisplay() nor (v.layer as! CATiledLayer).setNeedsDisplay() is the right way in this case. Both of the are flashing.

This is the basic implementation what I have added:

class RelationshipView: UIView {

    override class func layerClass() -> AnyClass {
        return CATiledLayer.self
    }

    override init(frame: CGRect) {
        super.init(frame: frame)

        (self.layer as! CATiledLayer).levelsOfDetail = 1
        (self.layer as! CATiledLayer).levelsOfDetailBias = 3
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func drawRect(rect: CGRect) {

UPDATE

Meantime I have subclassed CATiledLayer and using FastCATiledLayer with 0.0 fadeDuration return value instead of CATiledLayer like suggested here. But still flashing.

class FastCATiledLayer: CATiledLayer {

    override class func fadeDuration() -> CFTimeInterval {
        return 0.0
    }

    override func actionForKey(event: String!) -> CAAction! {

        if event == "contents" {
            return nil
        } else {
            return super.actionForKey(event)
        }
    }
}
Community
  • 1
  • 1
János
  • 32,867
  • 38
  • 193
  • 353

0 Answers0