作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我收到了后端的回复,格式如下,我想同时显示旁遮普语、古尔穆基语旁遮普语和英语的内容,
{
"AK_Index" = "APNE SEVAK KEE AAPE RAKE";
Ang = 747;
Author = "Guru Arjan Dev Ji";
Bani = "<null>";
"Bani_ID" = "<null>";
English = "Guru Nanak has met the Supreme Lord God; I am a sacrifice to Your Feet. ||4||1||47||";
"English_Initials" = gnmptckb;
Gurmukhi = "guru nwnku imilAw pwrbRhmu qyirAw crxw kau bilhwrw ]4]1]47]";
"Gurmukhi_Initials" = "gnmpqckb]";
ID = 32133;
Kirtan = Kirtan;
"Kirtan_ID" = 2853;
Punjabi = "gurU nwnk Awpxy prm pRBU nUM iml ipAw hY Aqy aus dy pYrW qoN GolI jWdw hY[";
Raag = "Raag Soohee";
"Teeka_Arth" = "hy pRBU! mYN qyry crnW qoN sdky jWdw hW[ ijs mnu`K nUM gurU nwnk iml ipAw, aus nUM prmwqmw iml ipAw ]4]1]47]";
"Teeka_Pad_Arth" = "kau = nUM, qoN ]4]1]47]";
}
附件是结果的截图。截图来自安卓。我想要在 iOS 中获得完全相同的结果。
最佳答案
我创建了一个扩展来更改某些特定字符串的颜色字体。
extension NSMutableAttributedString {
func setFontColorAndSize(_ textToFind : String,withColor color: UIColor,andFont font :UIFont){
let range = self.mutableString.range(of: textToFind, options: .caseInsensitive)
if range.location != NSNotFound {
setAttributes([NSAttributedStringKey.font : font,NSAttributedStringKey.foregroundColor :color], range: range)
}
}
// This is how you change
let resultString = NSMutableAttributedString(string: "hello") // convert any string to mutable attributed
resultString.setFontColorAndSize("hel", withColor: UIColor.grey, andFont: UIFont.boldSystemFont(ofSize: 17)) // pass the string you want to set particular color and font
UILabel.attributedText = resultString // than update the label
关于ios - 在 iOS 中加载旁遮普语文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50083675/
我是一名优秀的程序员,十分优秀!