我一直在尝试在clipsToBounds
到UITableViewCell
的子类中设置true
但不知何故再次成为false
:
class CustomCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.clipsToBounds = true
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
print(contentView.clipsToBounds) // false
super.layoutSubviews()
print(contentView.clipsToBounds) // false
}
}
是否有理由在false
中再次成为contentView
?我可以修理"这可以通过在clipsToBounds
中将true
设置为layoutSubviews()
,但感觉不对。
答案 0 :(得分:1)
您可以尝试在layoutSubviews()
中设置属性。
您还可以使用awakeFromNib()
功能将clipsToBounds
设置为true
..
答案 1 :(得分:0)
我认为在<div className="dropdown">
<button className="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<h6 style={{fontFamily: "'Open Sans', sans-serif",
fontSize: "12px", fontVariant: "small-caps"}}>
settings </h6>
<span className="glyphicon glyphicon-cog" />
</button>
<ul className="dropdown-menu" style={{textAlign: "center"}}>
<li>
<h5 style={{fontFamily: "'Open Sans', sans-serif", fontSize: "12px", fontVariant: "small-caps"}}>
user: {this.state.data.username} </h5>
</li>
<li style={{display: "inline-block"}}>
<button onClick={this.resetLayout} className="btn btn-default" style={{fontFamily: "'Open Sans', sans-serif",
fontSize: "12px", fontVariant: "small-caps"}}>
reset layout </button>
</li>
<li style={{display: "inline-block"}}>
<button className="btn btn-default" style={{fontFamily: "'Open Sans', sans-serif",
fontSize: "12px", fontVariant: "small-caps"}}>
<a href="/logout" style={{color: "black"}}> logout</a></button>
</li>
</ul>
</div>
上设置contentView
之后,有时会更改clipsToBounds = true
。请改为cell.contentView
。