8

Using this to copy UIView

UIView copyOfView = 
[NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:originalView]]

This throws the following error:

NSInvalidUnarchiveOperationException

[NSKeyedUnarchiver decodeBoolForKey]: value for key (UIHighlighted) is not a boolean

Yadvendar
  • 955
  • 9
  • 14

1 Answers1

3

If we are using Archive/Unarchive with UIImageView , I am facing error, though I fixed that highlight issue.

let NewView = whichView.snapshotView(afterScreenUpdates: true)!

The above line will give you best solution.

McDonal_11
  • 3,935
  • 6
  • 24
  • 55