Add image to alert view

后端 未结 5 1795
鱼传尺愫
鱼传尺愫 2021-02-02 12:08

I have an alert view that pops up when the user press the add button. How do i add an image to the alert view?

I added some code that i took reference from stack overfl

5条回答
  •  爱一瞬间的悲伤
    2021-02-02 12:34

    It wasn't immediately clear to me what @Kakumanu's ImageContext stuff was for, but that's to resize the UIImage. Perhaps a slightly more Swifty way of doing it would be through a UIImage extension ```

    extension UIImage {
    /// Resize a UIImage
    func imageWith(newSize: CGSize) -> UIImage {
        let renderer = UIGraphicsImageRenderer(size: newSize)
        let image = renderer.image { _ in
            self.draw(in: CGRect.init(origin: CGPoint.zero, size: newSize))
        }
        return image.withRenderingMode(self.renderingMode)
    }
    

    }

提交回复
热议问题