简体   繁体   English

如何将R.swift用于字符串和颜色

[英]How to use R.swift for string and colors

So I have a simple question.I searched a lot and there was no such a clear answer to my question. 所以我有一个简单的问题,我搜索了很多,但对我的问题却没有如此明确的答案。 How can I use R.swfit for Colors and Localized String ? 如何将R.swfit用于颜色和本地化字符串? R.swift completely recognize my images and fonts but how can I use them for my Colors and Localized. R.swift可以完全识别我的图像和字体,但是如何将它们用于“颜色”和“本地化”。 I have so many colors and Localized String in my Project but R.string and R.color are empty at all 我的项目中有很多颜色和本地化字符串,但是R.stringR.color是空的

I found the answer.I was wrong about working of R.swift.for using Colors you have to define them in Assets.xcassets as a new color set.after creating colors there you can use them via R.color . 我找到了答案.R.swift的工作方式是错误的,因为要使用颜色,您必须在Assets.xcassets中将它们定义为新的颜色集。创建颜色之后,可以通过R.color使用它们。 for using R.string you have to create new File.string file into your project and try to define string in key-value form like "variable" = "something" .after that you can use R.string.File.variable() for using that string 要使用R.string您必须在项目中创建新的File.string文件,并尝试以键值形式(例如"variable" = "something"定义字符串。之后,您可以使用R.string.File.variable()用于使用该字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM