Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 在textview的每一行中创建一个作为项目符号的图像_Swift_Textview_Nstextattachment_Bulletedlist - Fatal编程技术网

Swift 在textview的每一行中创建一个作为项目符号的图像

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

我试图在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
    }
    

  • 请不要将源代码作为图像包含在内。