我试图使用类似于TextView中的项目符号列表而不是子弹我有一个图像。问题在于,当我按正常情况创建新行时,\n
"在行中的图像可编辑之前签署空格。
而且我想让这个图像始终首先排成一行
所以我要问:
你不能在子弹之前传递文字
private var stringWithNewPointersInside = NSMutableAttributedString()
private var pointerAsTextValue = NSAttributedString()
private var image = UIImage()
private var imageView = UIImageView()
private let pointer = NSTextAttachment()
public func checkList(noteTextValue: NSAttributedString) -> NSMutableAttributedString {
stringWithNewPointersInside = NSMutableAttributedString(attributedString: noteTextValue)
stringWithNewPointersInside.append(NSAttributedString(string: "\n"))
pointer.image = createImage(name: EMPTY_TICK_IMAGE, newSize: CGSize(width: WIDTH, height: HEIGHT))
pointerAsTextValue = NSAttributedString(attachment: pointer)
stringWithNewPointersInside.append(pointerAsTextValue)
stringWithNewPointersInside.append(NSAttributedString(string: " "))
return stringWithNewPointersInside
}
private func createImage(name: String, newSize: CGSize) -> UIImage{
var newImage = UIImage(named: name)!
UIGraphicsBeginImageContext(newSize)
newImage.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height))
newImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return newImage
}