我想知道是否有可能在没有UIImageView图层动画的情况下为UIImageView内部的视图设置动画。我想让边框不生动,并且要将图像剪裁到边框上,但要根据需要将图像淡入淡出。swift 3褪色图像,而不是UIImage层
我动画这样的:
func animateStart() {
UIView.animate(withDuration: 3, animations: {
self.firstImg.image = UIImage(named:"peter.JPG")
self.firstImg.alpha = 1
}, completion: { finished in
if finished {
self.animateSecond()
}
})
}
设置边界,如:
class RoundedImage: UIImageView {
override func awakeFromNib() {
self.layer.borderWidth = 5
self.layer.borderColor = UIColor.darkGray.cgColor
self.layer.cornerRadius = 15
self.clipsToBounds = true
}
我猜你不能这样做。将您的imageView作为子视图添加到具有配置边框的相同大小的UIView。并在里面设置动画效果。 –