Open junwangInChina opened 8 years ago
使用widthRatioToView与heightRatioToView函数时,传入的第二个参数必须为float类型。 这样就可以:widthRatioToView(self.view1, 0.5).heightRatioToView(self.view1, 0.5); 这样就不行:widthRatioToView(self.view1, 1/2).heightRatioToView(self.view1, 1/2); 这样也不行:widthRatioToView(self.view1, (1/2)).heightRatioToView(self.view1, (1/2));
你看下 1/2 的值 应该 为0 ,所以显示不出来,你用 1.0/2 再试下应该就可以了
使用widthRatioToView与heightRatioToView函数时,传入的第二个参数必须为float类型。 这样就可以:widthRatioToView(self.view1, 0.5).heightRatioToView(self.view1, 0.5); 这样就不行:widthRatioToView(self.view1, 1/2).heightRatioToView(self.view1, 1/2); 这样也不行:widthRatioToView(self.view1, (1/2)).heightRatioToView(self.view1, (1/2));