iOS 13 WWDC Modernizing Your UI for iOS 13 視頻相關

present 新增 modalPresentationStyle

.pageSheet .fromSheet
iOS 13UIModalPresentationStyle 會默認為 .automatic,而.automatic大部分時間以.pageSheet形式展現(xiàn)

For most view controllers, UIKit maps this style to the UIModalPresentationStyle.pageSheet style, but some system view controllers may map to a different style.

而當present你自己所創(chuàng)建的vc時,即.pageSheet。 系統(tǒng)的UIImagePickerController則在選擇照片時會為.pageSheet,而拍照時為.fullScreen

表現(xiàn)形式:
iPhone中會一層一層往上推出,后面做一個scale


image.png

iPad上不會覆蓋全屏,而是居中的一個視圖,繼續(xù)present的話,會在中間一直疊加,如圖:


image.png

modalPresentationStyle.pageSheet時候,系統(tǒng)會為界面添加一個下拉返回的功能,如果一些界面不需要,那么如何禁掉該功能?
我們需要把新界面的isModalInPresentation設置為true即可。這是我們也能下拉拖拽,但只能拖拽一小部分距離。

當然我們還可以在用戶下拉的時候,來一個彈框詢問用戶是否真的要返回上級界面。那么界面需要遵循這個協(xié)議UIAdaptivePresentationControllerDelegate,該協(xié)議在iOS13中新增了兩個方法

func draftDidChange()

// 這個方法中我們可以彈框進行提醒,這個方法僅在isModalInPresentation為true的時候會觸發(fā)
func presentationControllerDidAttemptToDismiss(_: UIPresentationController)
image.png

UISearchController

Apple終于將UISearchbar中的UISearchTextField暴露為公共參數(shù)

Search Token
image.png
let selectedText = field.textIn(field.selectedTextRange) // "beach"
let token = UISearchToken(icon: nil, text: selectedText)
field.replaceTextualPortion(of: field.selectedTextRange, with: token, at: field.tokens.count)

UITableView和UICollectionview新特性

  • 兩個手指滑動即可觸發(fā)多選
  • iPad上如果有外接鍵盤,支持按著shiftcommand的情況下,單擊cell進行選擇,和Mac一樣的操作。
    UITableViewUICollectionView中新增兩個方法來實現(xiàn)上述操作
optional func tableView(_ tableView: UITableView, shouldBeginMultipleSelectionInteractionAtIndexPath indexPath: IndexPath) -> Bool

optional func tableView(_ tableView: UITableView, didBeginMultipleSelectionInteractionAtIndexPath indexPath: IndexPath)

UIContextMenuInteraction

image.png

效果如上圖,看起來很像 3D TouchPeek And Pop,官方給出的解釋

this sounds a lot like Peek and Pop in some ways. Well, we noticed that too.

However, since this new API provides a much larger feature set and works on multiple platforms, we are deprecating UIViewController previewing in iOS 13.

So, go and replace your implementation of Peek and Pop with UIContextMenuInteraction and give your users a consistent experience in your app across all devices.

所以。。。放棄3D Touch吧。

創(chuàng)建該類對象相關代碼如下:

let actionProvider = (suggestedActions: [UIMenuElement]) -> UIMenu? {
    let editMenu = UIMenu(title: "Edit...", children: [
        UIAction(title: "Copy") { ... },
        UIAction(title: "Duplicate") { ... }
    ])
    return UIMenu(children: [
        UIAction(title: "Share") { ... },
        editMenu,
        UIAction(title: "Delete", style: .destructive) { ... }
    ])
}.

return UIContextMenuConfiguration(identifier: "unique-ID" as NSCopying, previewProvider: nil, actionProvider: actionProvider)

UITableView也做了相應的支持,在UITableViewDelegate中添加了如下方法

optional func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAtIndexPath indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration?
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容