0

I want to create an animation where the screen will split from the center into two parts to open up to a new UIViewController.

Currently, I am trying to copy the layer into two variables, but I am not able to copy the layer. One layer will go to the right and the other to the left so it will look like opening doors.

Any help will be appreciated.

Caleb
  • 5,548
  • 3
  • 25
  • 32
Teenenggr
  • 93
  • 8

2 Answers2

2
    let ff = NSKeyedArchiver.archivedDataWithRootObject(fromViewController.view.layer)
    let ss = NSKeyedUnarchiver.unarchiveObjectWithData(ff) as! CALayer
    layer = ss


    let ff1 = NSKeyedArchiver.archivedDataWithRootObject(fromViewController.view.layer)
    let ss1 = NSKeyedUnarchiver.unarchiveObjectWithData(ff1) as! CALayer
    layer2 = ss1
Teenenggr
  • 93
  • 8
0

Unfortunately you cannot copy CALayer object and UIView instance too, but you can try a solution of the similar problem here: Can UIView be copied?

Community
  • 1
  • 1
dydus0x14
  • 111
  • 4
  • I am able to do so as but sometimes it takes time to load let ff = NSKeyedArchiver.archivedDataWithRootObject(fromViewController.view.layer) let ss = NSKeyedUnarchiver.unarchiveObjectWithData(ff) as! CALayer layer = ss let ff1 = NSKeyedArchiver.archivedDataWithRootObject(fromViewController.view.layer) let ss1 = NSKeyedUnarchiver.unarchiveObjectWithData(ff1) as! CALayer layer2 = ss1 – Teenenggr Feb 11 '16 at 17:13
  • how can i improve this ? – Teenenggr Feb 11 '16 at 17:15