Use images on Asset Catalog in Interface Builder

2019-08-11 13:22发布

Is it possible to use the images added to Assets Catalog directly on interface builder? How is that done?

On UIImageView properties I can't see any option to reference any image on assets catalog.

2条回答
霸刀☆藐视天下
2楼-- · 2019-08-11 13:36
  1. Import the images into the .xcassets folder
    • click the '+' in the bottom right, 'Import folder'
  2. Setup each image with its 1x and 2x image size
  3. Give it a name

Images can then be referenced programmatically with UIImage *image = [UIImage imageNamed:@"some-image"], or via the image dropdown in IB/Storyboards.

查看更多
forever°为你锁心
3楼-- · 2019-08-11 13:45

All of the images in an asset catalog have a name. This name can be used in imageNamed: and in IB.

查看更多
登录 后发表回答