Visualizing the Changing Sound of Music

As part of a week-long course on information visualisation at National Institute of Design by Amit Kapoor, I chose to analyse the top 100 songs from Billboard Music charts of 2008 and 2018. I wanted…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Using ImageRenderer to Convert SwiftUI Views into Images

ImageRenderer is another new API for SwiftUI that comes with iOS 16. It allows you to easily convert any SwiftUI views into an image. The implementation is very simple. You instantiate an instance of ImageRenderer with a view for the conversion:

You can then access the cgImage or uiImage property to retrieve the generated image.

First, let’s revisit the code of the ChartView example. We used the new API of the Charts framework to create a line chart and display the weather data. Here is the code snippet:

To use ImageRenderer, we first refactor this piece of code into a method like this:

Add a comment

Related posts:

PROGRAMING ORIENTED TO PROTOCOLS IN SWIFT

Programming oriented to protocols in Swift is a programming approach that focuses on using protocols to define the interfaces for a class or structure, rather than using inheritance. In Swift, a…

Agile Methodology at Zomato

Product development is a step by step process where all steps are equally important. These steps involve These steps can either be performed in a sequential manner or in a concurrent manner…