Swift 在textview的每一行中创建一个作为项目符号的图像
我试图在TextView中制作类似于项目符号列表的东西,但我没有项目符号,而是有一个图像。问题是,当我通过普通“Swift 在textview的每一行中创建一个作为项目符号的图像,swift,textview,nstextattachment,bulletedlist,Swift,Textview,Nstextattachment,Bulletedlist,我试图在TextView中制作类似于项目符号列表的东西,但我没有项目符号,而是有一个图像。问题是,当我通过普通“\n”创建新行时,请在行中的图像可编辑之前对空格进行签名。 我想让这张照片永远是第一个登录的人 所以我想问一下: 子弹点 而不是一个图像 你不能在子弹前传递文本 private var stringWithNewPointersInside = NSMutableAttributedString() private var pointerAsTextValue = NSAttribut
\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
}
请不要将源代码作为图像包含在内。