为iOS定制BottomAppBar中的晶圆厂
现在我想知道如何为iOS做同样的事情 实际上,我需要更改为iOS定制BottomAppBar中的晶圆厂,ios,floating-action-button,material-components-ios,Ios,Floating Action Button,Material Components Ios,现在我想知道如何为iOS做同样的事情 实际上,我需要更改fabCradleDiameter,fabCradleRoundedCornerRadius,fabCradleVerticalOffset和FAB radius 上面的文章显示,在Android上,它是通过一些布局xml中的app:*参数完成的。但是在iOS中没有这样的xml。在iOS touch中查看如何在执行时创建组件,要做到这一点,请按以下方式执行: var bottomAppBar: MDCBottomAppBarView {
fabCradleDiameter
,fabCradleRoundedCornerRadius
,fabCradleVerticalOffset
和FAB radius
上面的文章显示,在Android上,它是通过一些布局xml中的app:*参数完成的。但是在iOS中没有这样的xml。在iOS touch中查看如何在执行时创建组件,要做到这一点,请按以下方式执行:
var bottomAppBar: MDCBottomAppBarView {
let bottomAppBar = MDCBottomAppBarView()
// background color Bottom App Bar
bottomAppBar.barTintColor = UIColor(named: "Teal")
// Image floatingButton
bottomAppBar.floatingButton.setImage(UIImage(named: "CloudUpload"), for: .normal)
// Background color floatingButton
bottomAppBar.floatingButton.backgroundColor = UIColor(named: "Gray600")
// here you define the size of the bottom app bar, in my case I define the size based on a view that I added to the ViewController
let size = bottomAppBar.sizeThatFits(self.containerView.bounds.size)
bottomAppBar.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
// The following lines of code are to define the buttons on the right and left side
let barButtonLeadingItem = UIBarButtonItem(
image: UIImage(named:"IconName"), // Icon
style: .plain,
target: self,
action: #selector(self.onMenuButtonTapped))
let barButtonTrailingItem = UIBarButtonItem(
image: UIImage(named: "IconName"), // Icon
style: .plain,
target: self,
action: #selector(self.onNavigationButtonTapped))
bottomAppBar.leadingBarButtonItems = [barButtonLeadingItem]
bottomAppBar.trailingBarButtonItems = [barButtonTrailingItem]
return bottomAppBar
}
// Add bottombar to view
self.containerView.addSubview(bottomAppBar)
注意:以上代码在Swift 5.0中测试在iOS touch中查找以在执行时创建组件,要执行,请按以下方式执行:
var bottomAppBar: MDCBottomAppBarView {
let bottomAppBar = MDCBottomAppBarView()
// background color Bottom App Bar
bottomAppBar.barTintColor = UIColor(named: "Teal")
// Image floatingButton
bottomAppBar.floatingButton.setImage(UIImage(named: "CloudUpload"), for: .normal)
// Background color floatingButton
bottomAppBar.floatingButton.backgroundColor = UIColor(named: "Gray600")
// here you define the size of the bottom app bar, in my case I define the size based on a view that I added to the ViewController
let size = bottomAppBar.sizeThatFits(self.containerView.bounds.size)
bottomAppBar.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
// The following lines of code are to define the buttons on the right and left side
let barButtonLeadingItem = UIBarButtonItem(
image: UIImage(named:"IconName"), // Icon
style: .plain,
target: self,
action: #selector(self.onMenuButtonTapped))
let barButtonTrailingItem = UIBarButtonItem(
image: UIImage(named: "IconName"), // Icon
style: .plain,
target: self,
action: #selector(self.onNavigationButtonTapped))
bottomAppBar.leadingBarButtonItems = [barButtonLeadingItem]
bottomAppBar.trailingBarButtonItems = [barButtonTrailingItem]
return bottomAppBar
}
// Add bottombar to view
self.containerView.addSubview(bottomAppBar)
注意:以上代码在Swift 5.0中测试只有两个属性可用于更改浮动操作按钮大小,如何设置自定义大小我认为值得一提的是“MBCBottomAppBarView”的来源:只有两个属性可用于更改浮动操作按钮大小,如何设置自定义大小我认为值得一提的是“MBCBottomAppBarView”的来源: