Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change BackgroundColor of snackbar for ios?

My app uses a snackbar of material-components-ios. I want to change BackgroundColor to blue, but I can't.

So is it possible to change the background color of snackbar?

like image 249
Tamcha Avatar asked Nov 28 '22 20:11

Tamcha


2 Answers

You don't have to hack it :-)

Since you have added the swift tag to this question, then I'll give an answer with Swift code.

MDCSnackbarMessageView.appearance().snackbarMessageViewBackgroundColor = .green
MDCSnackbarManager.show(MDCSnackbarMessage(text: "Hi there"))
like image 124
Kumuluzz Avatar answered Dec 19 '22 17:12

Kumuluzz


I'm using MaterialComponents version 68.1. If you too, try this:

let message = MDCSnackbarMessage()
message.text = "message"

MDCSnackbarManager.messageTextColor = .white
MDCSnackbarManager.snackbarMessageViewBackgroundColor = .blue
MDCSnackbarManager.show(message)
like image 33
zyc Avatar answered Dec 19 '22 16:12

zyc