如何从框架资产中设置故事板中的图像

2023-05-17移动开发问题
4

本文介绍了如何从框架资产中设置故事板中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

在我的项目中,有一个框架项目,并且这个框架项目在资产目录中有图片..

In My Project, there is one framework project and this framework project has images in the assets catalog..

我想在我的主要项目的情节提要中使用这些图像.

I want to use theses images using the storyboard of my main project.

我可以通过像这样定义框架的捆绑包来使用类文件中的图像,

I can use the images in class files by defining the bundle of the framework like this,

myImageView.image = UIImage(named: "img1", in: Bundle.init(identifier: "com.abc"), compatibleWith: nil)

但不在情节提要中.所以我可以在情节提要中使用它还是只能使用代码?

but not in the storyboard. so Can I use it in storyboard or I have to go using code only ?

推荐答案

你不能直接使用其他框架的资产,但你可以将资产添加到你的主要目标作为参考:

You cannot use assets of other frameworks directly, but you can add the assets to your main target as reference:

将文件添加到 Project.xcodeproj..."

"Add Files to Project.xcodeproj..."

然后,您将能够在图像视图和按钮的属性检查器中选择资产容器的图像.

You will then be able to choose the images of the assets container in the attributes inspector of image views and buttons.

这篇关于如何从框架资产中设置故事板中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9