What is the difference between UIImage
and UIImageView
? Can someone explain it with an example?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
UIimage is an Object which stores data (Jpg, png...) and UIImageView class which contains UIImage as property. UIImageView can have multiple of UIImages, and UIImage is immutable. That bothered me long time ago, why when u create image you do: var image: UIImageView!
but when u execute that "image" you do image.image = UIImage.init(named: "image") Its really easy, you use UIimageView, to create image with UIImage :) UIImage displays image, and UIImageView is container for that UIImage
UIImage
objects store data from an image (i.e. data from a png file)UIImageView
objects are used to display aUIImage
UIImage
is a data object that holds image bytes.UIImageView
is a control that displayUIImage
data.create an instance for UIImageView as "myImage".This is helps for dispaly data.UIImage helps for hold the data of 1.png from the assets file in the xcode.
In short: You create an instance of
UIImage
object to hold image's data, like this:You then create an instance of
UIImageView
either through IB or code to display your image on the screen, like this:UIImage
contains the data for an image.UIImageView
is a custom view meant to display theUIImage
.