iphone,ipad重复UIView - 克隆视图 [英] iphone, ipad Duplicate UIView - Cloned View
问题描述
如何复制UIView。要求是在视图中应该有两个视图,以便考虑View A和View B.更改一个视图也应该改变另一个视图。
How to Duplicate a UIView. requirement is there should be two views inside a view for ex consider View A and View B. changing one view also should change another view.
例如考虑在视图中添加了一个mpmediaplayer A意味着视图B应该显示在视图A中的相同视频,如果我移动任何视图A意味着转发视频,音量控制等。scond view shold显示相同的东西。
for example consider am added a mpmediaplayer in view A means view B should show same video which is there in view A and if i moving anything in view A means ie forwarding video, volume control etc.. the scond view shold display the same thing.
推荐答案
没有简单的方法来克隆视图然后通过一行代码更新两个视图。因为他们的底层CALayers是不同的。但是为了复制UIView,可以使用一种新的方法:
使用UIView的方法:
There is no easy way to clone a view and then to update two views by one line of code. Because their underlying CALayers are different. But for duplicating a UIView, here is a new method you can use: Use UIView's method:
- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates
这是绘制视图的最快方法。在iOS 7中可用。
This is the fastest way to draw a view. Available in iOS 7.
这篇关于iphone,ipad重复UIView - 克隆视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!