Difference between UIImage and UIImageView

后端 未结 8 691
予麋鹿
予麋鹿 2021-01-31 16:24

What is the difference between UIImage and UIImageView? Can someone explain it with an example?

相关标签:
8条回答
  • 2021-01-31 16:41

    UIImage objects store data from an image (i.e. data from a png file)

    UIImageView objects are used to display a UIImage

    0 讨论(0)
  • 2021-01-31 16:50

    UIimage is an Object which stores data (Jpg, png...) and UIImageView class which contains UIImage as a property. UIImageView can have multiple UIImages, and UIImage is immutable. That bothered me a long time ago, when you create an image you do:

     var image: UIImageView!
    

    But when you execute that "image" you do

    image.image = UIImage.init(named: "image")
    

    Its really easy, you use UIimageView, to create an image with UIImage. UIImage displays the image, and UIImageView is a container for that UIImage.

    0 讨论(0)
提交回复
热议问题