以前我使用的是Xcode 6.4或更低版本,因为我没有通知此类型的问题。但是现在我在相关的CGRectMake x,y Position中的Xcode 7.2中遇到了明显的问题。
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
UIView *smallView=[[UIView alloc]initWithFrame:CGRectMake(screenWidth/2, screenHeight/2, 100, 100)];
smallView.backgroundColor=[UIColor redColor];
[self.view addSubview:smallView];
NSLog(@"%f",smallView.frame.origin.x);// 137.500000
但是如果我添加center = self.view.ceter它会来到中心。输出为
smallView.center=self.view.center;
问题是,在x和amp; y位置值相同,
NSLog(@"%f\n%f\n%f\f%f ",screenWidth/2,screenHeight/2,self.view.center.x,self.view.center.y);
为什么他们会显示不同的结果,我怎么能不使用中心属性。或者应该去Autolayout。