如何删除两个段落之间的空格?
Posted
技术标签:
【中文标题】如何删除两个段落之间的空格?【英文标题】:How to remove whitespace between two paragraphs? 【发布时间】:2016-05-03 10:57:01 【问题描述】:My image
我正在从 html 获取数据到文本。 现在请告诉我如何避免两段之间的空格?
func processGetDescriptionResponse(json: JSON)
let status = json.dictionaryObject!["status"] as? Bool
if status == true
let data = json.dictionaryValue["data"]!
let values = data.arrayValue
dataSourceDescription.removeAll()
for i in 0 ..< values.count
let description = Description.initWithJSON(values[i])
dataSourceDescription.append(description)
// DetailDescription.text = dataSourceDescription[i].content
if dataSourceDescription[i].file_url == ""
DetailImage.image = UIImage(named: "logo_two_fifty")
else
let imageURL = NSURL(string: baseURLString + dataSourceDescription[i].file_url!)
DetailImage.kf_setImageWithURL(imageURL!, placeholderImage: nil, optionsInfo: [.Transition(ImageTransition.Fade(50))]) (image, error, cacheType, imageURL) in
DetailDescription.attributedText = convertText(dataSourceDescription[i].content!)
print(DetailDescription.text)
else
【问题讨论】:
你能发布你的代码吗? 【参考方案1】:如果收到html内容,可以使用NSAttributedString
在UITextView
中显示:
let htmlString = "<html><body><p>Para 1</p><p>Para 2</p></body></html>"
let attributedString = try!
NSAttributedString(data: htmlString.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false)!,
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
yourTextView.attributedText = attributedString
【讨论】:
以上是关于如何删除两个段落之间的空格?的主要内容,如果未能解决你的问题,请参考以下文章