簡體   English   中英

iOS-像圖片一樣的presentViewController(在Messages中打開iMessages應用商店)

[英]iOS - presentViewController like the image (Open iMessages app store in Messages)

在Messages屏幕快照中打開iMessages應用程序商店

我想像上面的圖像一樣呈現一個UINavigationController ,我使用

nvc.modalPresentationStyle =  UIModalPresentationFormSheet;

但是我無法更改控制器的大小。

這是我做的:

UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor grayColor];

UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
nvc.modalPresentationStyle = UIModalPresentationFormSheet;

nvc.view.frame = CGRectInset(self.view.bounds, 20, 20);
[self presentViewController:nvc animated:YES completion:nil];

但是當前的viewController仍然是全屏。

可能是您可以按如下方式使用preferredContentSize

nvc.modalPresentationStyle =  UIModalPresentationFormSheet;

nvc.preferredContentSize = CGSizeMake(width, height);

喜歡,

nvc.preferredContentSize = CGSizeMake(300, 600);

要么

在Presented viewController的viewDidLoad方法中,編寫以下代碼:

self.preferredContentSize = CGSizeMake(width, height);

編輯:

  1. 選擇您的viewController或xib並將size屬性設置為Freeform

  2. 在屬性檢查器的“內容大小”中啟用用戶首選的顯式大小。

img1

有關更多詳細信息,請參見此處的答案:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM