Setting the background color of window

I want to set the background color of window. It seems in the older version I should write the code like this:

use iced::{ Application, Color };

struct MyApp {}

impl Application for MyApp {
    // ...

    fn background_color() -> Color {
        Color::TRANSPARENT // the transparent color
    }

    // ...
}

However, it seems in the 0.12.1 version the API is changed and I should code differently. How I do this?

What version do you mean by latest? If you mean the development branch, i.e. “0.13.0-dev”, then you would be creating your Application in mian() a bit differently, something like

pub fn main() -> iced::Result {
    iced::application("A counter", update, view).run()
}

In which case you need to supply a style callback function/closure

pub fn main() -> iced::Result {
    iced::application("A counter", update, view)
    .style(|_state, _theme| {
            Appearance {
                background_color: iced::Color::TRANSPARENT,
                text_color: Default::default(),
            }
    })
    .run()
}

I meant the version 0.12.1 which is currently the latest stable release version and available in crates.io.