mirror of
https://github.com/exyte/Macaw.git
synced 2024-08-15 08:00:31 +03:00
Fix some examples
This commit is contained in:
parent
9a73bc012f
commit
bb47def337
@ -115,13 +115,16 @@ extension AnimationProducer {
|
||||
// MARK: - Combine animation
|
||||
func addCombineAnimation(_ combineAnimation: Animation, _ context: AnimationContext) {
|
||||
guard let combine = combineAnimation as? CombineAnimation,
|
||||
let _ = combine.nodeRenderer,
|
||||
let node = combine.node else {
|
||||
return
|
||||
}
|
||||
|
||||
var animations = combine.animations
|
||||
let childAnimations = createChildAnimations(combine) as! [BasicAnimation]
|
||||
animations.append(contentsOf: childAnimations)
|
||||
if let _ = combine.node?.bounds, let _ = combine.toNodes.group().bounds {
|
||||
let childAnimations = createChildAnimations(combine) as! [BasicAnimation]
|
||||
animations.append(contentsOf: childAnimations)
|
||||
}
|
||||
|
||||
// Reversing
|
||||
if combine.autoreverses {
|
||||
|
@ -74,9 +74,8 @@ open class MacawView: MView {
|
||||
@objc public init?(node: Node, coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
if let drawingView = DrawingView(node: node, coder: aDecoder) {
|
||||
self.drawingView = drawingView
|
||||
}
|
||||
self.node = node
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, view: drawingView)
|
||||
|
||||
zoom.initialize(view: self, onChange: onZoomChange)
|
||||
}
|
||||
@ -84,14 +83,13 @@ open class MacawView: MView {
|
||||
public convenience init(node: Node, frame: CGRect) {
|
||||
self.init(frame: frame)
|
||||
|
||||
self.drawingView = DrawingView(node: node, frame: frame)
|
||||
self.node = node
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, view: drawingView)
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
self.drawingView = DrawingView(frame: frame)
|
||||
|
||||
zoom.initialize(view: self, onChange: onZoomChange)
|
||||
}
|
||||
|
||||
@ -107,21 +105,27 @@ open class MacawView: MView {
|
||||
initializeView()
|
||||
}
|
||||
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
drawingView.frame = self.bounds
|
||||
}
|
||||
|
||||
func initializeView() {
|
||||
|
||||
if !self.subviews.contains(drawingView) {
|
||||
self.backgroundColor = .white
|
||||
self.clipsToBounds = true
|
||||
if self.backgroundColor == nil {
|
||||
self.backgroundColor = .white
|
||||
}
|
||||
drawingView.removeFromSuperview()
|
||||
self.addSubview(drawingView)
|
||||
drawingView.backgroundColor = .white
|
||||
drawingView.isUserInteractionEnabled = false
|
||||
drawingView.backgroundColor = .clear
|
||||
drawingView.initializeView()
|
||||
|
||||
drawingView.translatesAutoresizingMaskIntoConstraints = false
|
||||
drawingView.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true
|
||||
drawingView.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true
|
||||
drawingView.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
|
||||
drawingView.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
|
||||
#if os(iOS)
|
||||
self.clipsToBounds = true
|
||||
drawingView.isUserInteractionEnabled = false
|
||||
#endif
|
||||
}
|
||||
|
||||
let tapRecognizer = MTapGestureRecognizer(target: drawingView, action: #selector(DrawingView.handleTap(recognizer:)))
|
||||
@ -277,24 +281,8 @@ internal class DrawingView: MView, MGestureRecognizerDelegate {
|
||||
self.context = RenderContext(view: self)
|
||||
}
|
||||
|
||||
@objc public convenience required init?(coder aDecoder: NSCoder) {
|
||||
self.init(node: Group(), coder: aDecoder)
|
||||
}
|
||||
|
||||
@objc public init?(node: Node, coder aDecoder: NSCoder) {
|
||||
@objc public required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
self.node = node
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, view: self)
|
||||
backgroundColor = .white
|
||||
}
|
||||
|
||||
public convenience init(node: Node, frame: CGRect) {
|
||||
self.init(frame: frame)
|
||||
|
||||
self.node = node
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, view: self)
|
||||
backgroundColor = .white
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
|
Loading…
Reference in New Issue
Block a user