In the for
loop I am trying to place images from arrayOfImages
in rectangles that I've created with CGRect
.
But after that I want to use class MyClassView
which inherits UIView
, because I have there additional functions that I want to apply on my rectangle images that I've just created, but I am getting the error
cannot assign value of type UIView to type CGRect
let widthRect = 50
func createMyRects(){
let insetSize = CGRectInset(self.view.bounds, CGFloat(Int(widthRect)), CGFloat(Int(widthRect))).size
for i in 0...arrayOfImages.count-1{
let pointX = CGFloat(UInt(arc4random() % UInt32(UInt(insetSize.width))))
let pointY = CGFloat(UInt(arc4random() % UInt32(UInt(insetSize.height))))
let showImages = UIImageView(image: arrayOfImages[i])
let newFrame = CGRect(x: pointX, y: pointY, width: CGFloat(widthRect), height: CGFloat(widthRect))
//showImages.frame = newFrame
let newFrame2 = MyClassView(frame: newFrame)
showImages.frame = newFrame2 //here it says: cannot assign value of type UIView view to type CGRect
view.addSubview(showImages)
}
}
Aucun commentaire:
Enregistrer un commentaire