Sharing bundled assets between app and extension

后端 未结 5 1953
迷失自我
迷失自我 2021-01-30 23:40

My Photo Sharing extension plans to use the same design assets (for navigation and for adding \'stamps / stickers\' to the photo).

As explained in App Sa

5条回答
  •  自闭症患者
    2021-01-30 23:49

    Assets can be added to a framework and reused in both app/extension. See "Loading Resources From A Framework" for more details.

      public class AmazingView: UIView {
      private func setupView() {
        let bundle = Bundle(for: AmazingView.self)
        guard let image = UIImage(named: "MyImage", in: bundle, compatibileWith: nil) else {
          fatalError("Missing MyImage...")
        }
      }
    }
    

提交回复
热议问题