我目前正在制作 ipad 应用程序。
我创建了一个带有模态演示的 uiviewcontroller。
当我打开这个 View 时,它是模糊的,我不知道为什么......
看,左边是清晰的,右边是模糊的:
我的代码:
- (IBAction)showView:(id)sender {
Myviewcontroller *myviewcontroller = [[Myviewcontroller alloc] initWithNibName:@"Myviewcontroller" bundle:nil];
myviewcontroller.modalPresentationStyle = UIModalPresentationFormSheet;
myviewcontroller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:myviewcontroller animated:YES];
myviewcontroller.view.superview.frame = CGRectMake(0, 0, 635, 400);
myviewcontroller.view.superview.center = self.view.center;
}
你有什么主意吗 ?
谢谢你的帮助
最佳答案
我猜 635
的宽度居中 View 时会导致问题:
(1024-635) / 2 = 194,5
(768-635) / 2 = 66,5
Core Graphics 将坐标处理为浮点数,而不是整数,因此以亚像素精度定位 View 是可能的,并且会产生这种抗锯齿效果,如模糊效果。这是可能的,因为 View 坐标是用 CGRect 指定的,它使用 CGPoint,其中 x 和 y 是浮点数。
尝试
636
的宽度像素代替,你应该没问题:)
关于objective-c - 使用 UIModalPresentationFormSheet 的 View 模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9409314/