-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help with Toolbar, leftViews too wide #618
Comments
taking a look now :) |
I got it working, and now only need to make sure there are not any regressions. I needed to make an update to Material. I will post an update very soon. I am aiming for tonight :) |
I made some updates to Material, which will come out in an hour. Here is the code you can use, that was modified from the ToolbarController sample. Basically, you need a container view that is used for the Toolbar calculations, and then you can center an image within there :) class AppToolbarController: ToolbarController {
fileprivate var profileView: UIView!
open override func prepare() {
super.prepare()
prepareProfileView()
prepareStatusBar()
prepareToolbar()
}
}
extension AppToolbarController {
fileprivate func prepareProfileView() {
profileView = UIView()
let imageView = View()
imageView.shapePreset = .circle
imageView.image = UIImage(named: "daniel")
profileView.layout(imageView).width(30).height(30).center()
}
fileprivate func prepareStatusBar() {
statusBarStyle = .lightContent
statusBar.backgroundColor = Color.blue.darken3
}
fileprivate func prepareToolbar() {
toolbar.interimSpacePreset = .interimSpace4
toolbar.backgroundColor = Color.blue.darken2
toolbar.leftViews = [profileView]
}
} |
That looks great! Will test it tomorrow. |
Please update to Material 2.4.0 for a solution to this issue :) |
It Works™ |
wonderful :) |
I'm not sure if this is an iOS thing or Material thing...
In your sample ToolbarController I'm trying to add an image instead of a button as the leftViews.
I've added this function
and replaced
with
I'm expecting the image to be a circular image 40x40, but it's too wide. What am I doing wrong?
See attached image.
The text was updated successfully, but these errors were encountered: