objective-c - 使用 UIModalPresentationFormSheet 的 View 模糊

标签 objective-c ios uiview

我目前正在制作 ipad 应用程序。

我创建了一个带有模态演示的 uiviewcontroller。

当我打开这个 View 时,它是模糊的,我不知道为什么......

看,左边是清晰的,右边是模糊的:

enter image description here

我的代码:

- (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/

相关文章:

objective-c - NSImage 不缩放

ios - 以编程方式创建 UIView

iOS 音量按钮 Controller 应用程序按钮

ios - 如何自定义 FSCalendar

iphone - 如何部分访问其父 uiview 之外的 uiview subview ?

ios - 圆形/圆形 UIView Swift - 不是没有角半径的正方形

ios - 展示广告时 Facebook 受众网络崩溃

ios - 枚举 UITableViewCell

objective-c - 无法安装到 iPhone 模拟器

iOS:全页插页式广告关闭后显示黑屏