Open jiachenmu opened 7 years ago
In LayoutKitDemo
, i found this:
open class CircleImagePileView: UIView {
open override func addSubview(_ view: UIView) {
// Make sure views are inserted below existing views so that the first image in the face pile is on top.
if let lastSubview = subviews.last {
insertSubview(view, belowSubview: lastSubview)
} else {
super.addSubview(view)
}
}
}
override UIVisualEffectView.addSubview
, is a solution?
What I guess above is a solution, here's an example:
class RootCardLayout: SizeLayout<VisualEffectView> {
init(_ title: String, subtitle: String, info: String, size: CGSize, action: @escaping (() -> ())) {
let titleLayout = LabelLayout.init(text: title, font: UIFont.cic.systemFont, numberOfLines: 1, viewReuseId: "title") { (label) in
}
let subtitleLayout = LabelLayout.init(text: subtitle, font: UIFont.boldSystemFont(ofSize: 20.0), numberOfLines: 0, viewReuseId: "subtitle") { (label) in
}
let infoHeight = info.cicHeight(size.width, font: UIFont.cic.preferred(.body))
let infoLayout = SizeLayout<CICLabel>.init(height: infoHeight) { (label) in
label.line(0)
.text(info)
.font(UIFont.preferredFont(forTextStyle: .body))
.sizeTo(layout: .maxWidth(.screenWidth))
.textColor(CIComponentKitThemeCurrentConfig.textColor)
.longPressAction(.copy)
.copyRange(NSMakeRange(0, 5))
label.copySuccessClousure = {
let tips = """
嫉妒使我高斯模糊
嫉妒使我氧化分解
嫉妒使我增减反同
嫉妒使我奇变偶不变符号看象限
嫉妒使我基因突变
嫉妒使我质壁分离
嫉妒使我泰拳警告
嫉妒使我弥散性血管内凝血
"""
CICHUD.showAlert("羡慕使我嫉妒", content: tips)
CICHUD.showNotifier(title: "爱酱今天要元气满满哦~")
}
}
let stackLayout = StackLayout<UIControl>.init(axis: .vertical,
spacing: 30,
sublayouts: [titleLayout, subtitleLayout, infoLayout]) { (control) in
control.addHandler(for: .touchUpInside, handler: { (_) in
action()
})
}
super.init(minWidth: size.width,
maxWidth: size.width,
maxHeight: size.height,
alignment: .center,
sublayout: InsetLayout.init(insets: UIEdgeInsetsMake(5, 5, 5, 5), sublayout: stackLayout)) { (view) in
view.layer.cornerRadius = 6.0
view.layer.masksToBounds = true
view.layer.shadowColor = UIColor.white.cgColor
view.effect = UIBlurEffect.init(style: .extraLight)
}
}
}
class VisualEffectView: UIVisualEffectView {
override func addSubview(_ view: UIView) {
print(view.classForCoder)
if view is UIControl {
self.contentView.addSubview(view)
}else {
super.addSubview(view)
}
}
}
override this method ,addSubview
, but may not be the best solution (-_-#!)
like the kind of
View.contenView
eg:it will crash:
Is there some solutions? thanks.. 😬