【发布时间】:2020-12-12 20:37:54
【问题描述】:
我的父视图四面都有圆角,我希望子图像视图的右上角和右下角都有圆角以适合父视图。 Swift documentation 说 masksToBounds 会解决这个问题,但它对我不起作用。从照片中可以看出,照片的右侧没有在右侧倒圆。如果您想查看我的更多代码,请告诉我,谢谢。
这是我的代码:
bottomViewThumbnailImageView.translatesAutoresizingMaskIntoConstraints = false
bottomViewThumbnailImageView.clipsToBounds = true
bottomViewThumbnailImageView.layer.masksToBounds = true
NSLayoutConstraint.activate([
bottomViewThumbnailImageView.topAnchor.constraint(equalTo: bottomView.topAnchor),
bottomViewThumbnailImageView.bottomAnchor.constraint(equalTo: bottomView.bottomAnchor),
bottomViewThumbnailImageView.trailingAnchor.constraint(equalTo: bottomView.trailingAnchor),
bottomViewThumbnailImageView.heightAnchor.constraint(equalTo: bottomViewThumbnailImageView.widthAnchor),
])
【问题讨论】: