Draggable, resizable and rotatable UIView implemented using protocols in Swift. Uses RxCocoa, RxGesture and RxSwift to avoid protocol extension restrictions.
TransformableView
is a composition of DraggableView
, ResizableView
and RotatableView
. Implement desired protocol as needed.
class View: UIView, TransformableView {}
class NonRotatableView: UIView, DraggableView, ResizableView {}
Protocols require var disposeBag: DisposeBag { get }
and include optional func didUpdate(frame: CGRect)
and func didUpdate(rotation: CGFloat)
methods.
Finnaly, add gesture handling
view.addGesturesHandling()
Demo is included in the project.