【问题标题】:Create UIimage from three sf symbols next to each other [closed]从彼此相邻的三个 sf 符号创建 UIimage [关闭]
【发布时间】:2021-05-30 13:21:07
【问题描述】:

我想制作一个 UIImage,它是三个彼此相邻的 UIImage(system:"star"),例如 *** 其中 * 是星形图像。知道如何以编程方式执行此操作吗?

【问题讨论】:

    标签: ios swift macos


    【解决方案1】:

    将您的图像绘制到自定义上下文中 3 次。

    func makeThreeStar() -> UIImage?  {
        guard let star = UIImage(systemName: "star") else { return nil }
        let size = CGSize(width: star.size.width * 3, height: star.size.height)
        let renderer = UIGraphicsImageRenderer(size: size)
        let image = renderer.image { ctx in
            for index in 0...2 {
                let point = CGPoint(x: star.size.width * CGFloat(index), y: 0)
                star.draw(at: point )
            }
        }
        return image
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-03
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 2017-04-18
      • 2018-03-31
      相关资源
      最近更新 更多