Skip to content

Commit

Permalink
fix: WrapperRowCell
Browse files Browse the repository at this point in the history
  • Loading branch information
fun committed Jun 29, 2022
1 parent ce5b729 commit 681c5c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Jenga.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Jenga"
s.version = "1.1.0"
s.version = "1.1.1"
s.summary = "像SwiftUI一样使用DSL代码搭建UITableView"

s.homepage = "https://github.com/fanglinwei/Jenga"
Expand Down
13 changes: 13 additions & 0 deletions JengaExample/JengaExample/Examples/ViewRowViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ fileprivate class BannerView: UIView, TableRowView {

private lazy var coverImageView = UIImageView(image: UIImage(named: "image1")!)

private lazy var button = UIButton()

override init(frame: CGRect) {
super.init(frame: frame)
setup()
Expand All @@ -45,11 +47,17 @@ fileprivate class BannerView: UIView, TableRowView {

private func setup() {
addSubview(coverImageView)
addSubview(button)

button.setTitle("点击", for: .normal)
button.setTitleColor(.red, for: .normal)
button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
}

override func layoutSubviews() {
super.layoutSubviews()
coverImageView.frame = bounds
button.frame = CGRect.init(x: 0, y: 50, width: 50, height: 30)
}

typealias Data = Int
Expand All @@ -58,5 +66,10 @@ fileprivate class BannerView: UIView, TableRowView {
print("===============")
print(data)
}

@objc
private func buttonAction() {
print("123")
}
}

4 changes: 2 additions & 2 deletions Sources/Jenga/Core/Cell/WrapperRowCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public class WrapperRowCell<View: TableRowView>: UITableViewCell {
}

func setup() {
addSubview(view)
contentView.addSubview(view)
}

open override func layoutSubviews() {
super.layoutSubviews()
view.frameWithoutTransform = bounds.inset(by: edgeInsets)
view.frameWithoutTransform = contentView.bounds.inset(by: edgeInsets)
}

open override func sizeThatFits(_ size: CGSize) -> CGSize {
Expand Down

0 comments on commit 681c5c0

Please sign in to comment.