My problem is that I created simple path with CABasicAnimation
from circle to roundedRect. I simply use two cashapelayers for each shape with uibezierpath, and because circle can be showed as roundedrect I used it twice and added them onto view, and it is working like a charm on iphone 6 and above, but strange things happen with edges when im trying launch it on iphone 5 and below (see gif). Im struggling with it almost 2 days and have no clue. Btw. red circle is a button and it's above those shapes. Here is code:
class Shapes: CAShapeLayer {
var circleLayer : UIBezierPath {
return UIBezierPath(roundedRect: CGRect(x: -(buttonWidth/2), y: -(buttonHeight/2), width: buttonWidth, height: buttonHeight), cornerRadius: 15)
}
var roundedRectLayer: UIBezierPath {
return UIBezierPath(roundedRect: CGRect(x: -(frame.width/2), y: -(frame.height/2), width: frame.width, height: frame.height), cornerRadius: 20)
}
func openMenu(){
let openMenu: CABasicAnimation = CABasicAnimation(keyPath: "path")
openMenu.fromValue = circleLayer.cgPath
openMenu.toValue = roundedRectLayer.cgPath
openMenu.duration = 0.4
openMenu.beginTime = CACurrentMediaTime() + 0.2
openMenu.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
openMenu.fillMode = kCAFillModeForwards
openMenu.isRemovedOnCompletion = false
add(openMenu, forKey: "openMenu")
}
}
and this is instantiated in another class of uiview which is that white rect below, this way:
let shapes = Shapes()
layer.addSublayer(shapes)
shapes.frame = CGRect(x: redButton.frame.midX, y: redButton.frame.midY, width: 320, height: redButton.frame.height + 10)
iPhone 5:
iPhone 6: