Скопировать/клонировать UIView в Swift в 2021 году?IOS

Программируем под IOS
Anonymous
Скопировать/клонировать UIView в Swift в 2021 году?

Сообщение Anonymous »


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

Вернуться в «IOS»