【背景】
参考:
MHTabBarController/MHTabBarController.m at master · hollance/MHTabBarController · GitHub
尝试把OC代码改为swift代码,借鉴的去实现自己的自定义的tab,结果代码:
class RecordTabBarController : UIViewController { override func viewDidLoad() { super.viewDidLoad() self.view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
出错:
RecordTabBarController.swift:17:71: Binary operator ‘|’ cannot be applied to two ‘UIViewAutoresizing’ operands
【解决过程】
1.搜:
swift Binary operator | cannot be applied to two UIViewAutoresizing operands
参考:
ios – Binary operator ‘|’ cannot be applied to two UIViewAutoresizing operands – Stack Overflow
去改为:
self.view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
即可。
【总结】
swift新语法,把:
self.view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
换成:
self.view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
才可以。
转载请注明:在路上 » 【已解决】swift代码出错:Binary operator | cannot be applied to two UIViewAutoresizing operands