Скопировать/клонировать UIView в Swift в 2021 году? ⇐ IOS
-
Anonymous
Скопировать/клонировать UIView в Swift в 2021 году?
There some similar questions but the answers use deprecated methods.
My solution which is similar to them but with modern methods:
func copyObject() throws -> T? { let data = try NSKeyedArchiver.archivedData(withRootObject:self, requiringSecureCoding:false) return try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? T } The problem is it doesn't work fully (and it seems the other questions-answers have the same problem) - one of subviews has corner radius which is not copied. How to solve this issue?
Источник: https://stackoverflow.com/questions/686 ... ft-in-2021
There some similar questions but the answers use deprecated methods.
My solution which is similar to them but with modern methods:
func copyObject() throws -> T? { let data = try NSKeyedArchiver.archivedData(withRootObject:self, requiringSecureCoding:false) return try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? T } The problem is it doesn't work fully (and it seems the other questions-answers have the same problem) - one of subviews has corner radius which is not copied. How to solve this issue?
Источник: https://stackoverflow.com/questions/686 ... ft-in-2021
Мобильная версия