我想知道是否可以在不动画UIImageView层的情况下为UIImageView内部的视图设置动画。我希望边框不要动画,并且图像要剪切到边框,但是图像要根据需要淡入和淡出。
我是这样的动画: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
}