mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
50 lines
1,009 B
Swift
50 lines
1,009 B
Swift
//
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@objc
|
|
class OWSLayerView: UIView {
|
|
let layoutCallback: ((UIView) -> Void)
|
|
|
|
@objc
|
|
public required init(frame: CGRect, layoutCallback : @escaping (UIView) -> Void) {
|
|
self.layoutCallback = layoutCallback
|
|
super.init(frame: frame)
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
self.layoutCallback = { _ in
|
|
}
|
|
super.init(coder: aDecoder)
|
|
}
|
|
|
|
override var bounds: CGRect {
|
|
didSet {
|
|
updateLayer()
|
|
}
|
|
}
|
|
|
|
override var frame: CGRect {
|
|
didSet {
|
|
updateLayer()
|
|
}
|
|
}
|
|
|
|
override var center: CGPoint {
|
|
didSet {
|
|
updateLayer()
|
|
}
|
|
}
|
|
|
|
private func updateLayer() {
|
|
// Prevent the shape layer from animating changes.
|
|
CATransaction.begin()
|
|
CATransaction.setDisableActions(true)
|
|
|
|
layoutCallback(self)
|
|
|
|
CATransaction.commit()
|
|
}
|
|
}
|