.markdown-body hr::after,.markdown-body::after { clear: both }
.loopLine,.messageLine0 { }
.markdown-body { color: #24292e; font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 1.5 }
.markdown-body .pl-c { color: #969896 }
.markdown-body .pl-c1,.markdown-body .pl-s .pl-v { color: #0086b3 }
.markdown-body .pl-e,.markdown-body .pl-en { color: #795da3 }
.markdown-body .pl-s .pl-s1,.markdown-body .pl-smi { color: #333 }
.markdown-body .pl-ent { color: #63a35c }
.markdown-body .pl-k { color: #a71d5d }
.markdown-body .pl-pds,.markdown-body .pl-s,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sra,.markdown-body .pl-sr .pl-sre { color: #183691 }
.markdown-body .pl-smw,.markdown-body .pl-v { color: #ed6a43 }
.markdown-body .pl-bu { color: #b52a1d }
.markdown-body .pl-c2,.markdown-body .pl-ii { color: #f8f8f8; background-color: #b52a1d }
.markdown-body .pl-c2::before { content: "^M" }
.markdown-body .pl-sr .pl-cce { font-weight: 700; color: #63a35c }
.markdown-body .pl-ml { color: #693a17 }
.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms { font-weight: 700; color: #1d3e81 }
.markdown-body .pl-mq { color: teal }
.markdown-body .pl-mi { font-style: italic; color: #333 }
.markdown-body .pl-mb { font-weight: 700; color: #333 }
.markdown-body .pl-md { color: #bd2c00; background-color: #ffecec }
.markdown-body .pl-mi1 { color: #55a532; background-color: #eaffea }
.markdown-body .pl-mc { color: #ef9700; background-color: #ffe3b4 }
.markdown-body .pl-mi2 { color: #d8d8d8; background-color: grey }
.markdown-body .pl-mdr { font-weight: 700; color: #795da3 }
.markdown-body .pl-mo { color: #1d3e81 }
.markdown-body .pl-ba { color: #595e62 }
.markdown-body .pl-sg { color: silver }
.markdown-body .pl-corl { text-decoration: underline; color: #183691 }
.markdown-body .octicon { display: inline-block; vertical-align: text-bottom }
.markdown-body hr::after,.markdown-body hr::before,.markdown-body::after,.markdown-body::before { display: table; content: "" }
.markdown-body a { background-color: transparent; color: #0366d6; text-decoration: none }
.markdown-body a:active,.markdown-body a:hover { outline-width: 0 }
.markdown-body h1 { margin: .67em 0 }
.markdown-body img { border-style: none }
.markdown-body svg:not(:root) { overflow: hidden }
.markdown-body hr { }
.markdown-body input { font: inherit; margin: 0; overflow: visible; font-family: inherit; font-size: inherit; line-height: inherit }
.markdown-body [type="checkbox"] { padding: 0 }
.markdown-body * { }
.markdown-body a:hover { text-decoration: underline }
.markdown-body strong { font-weight: 600 }
.markdown-body td,.markdown-body th { padding: 0 }
.markdown-body blockquote { margin: 0 }
.markdown-body ol ol,.markdown-body ul ol { list-style-type: lower-roman }
.markdown-body ol ol ol,.markdown-body ol ul ol,.markdown-body ul ol ol,.markdown-body ul ul ol { list-style-type: lower-alpha }
.markdown-body .task-list-item,ul.table-of-contents { list-style-type: none }
.markdown-body dd { margin-left: 0 }
.markdown-body code { font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace }
.markdown-body pre { font: 12px SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace }
.markdown-body .pl-0 { padding-left: 0 !important }
.markdown-body .pl-1 { padding-left: 4px !important }
.markdown-body .pl-2 { padding-left: 8px !important }
.markdown-body .pl-3 { padding-left: 16px !important }
.markdown-body .pl-4 { padding-left: 24px !important }
.markdown-body .pl-5 { padding-left: 32px !important }
.markdown-body .pl-6 { padding-left: 40px !important }
.markdown-body>:first-child { margin-top: 0 !important }
.markdown-body>:last-child { margin-bottom: 0 !important }
.markdown-body a:not([href]) { color: inherit; text-decoration: none }
.markdown-body .anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1 }
.markdown-body .anchor:focus { outline: 0 }
.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul { margin-top: 0; margin-bottom: 16px }
.markdown-body hr { overflow: hidden; background: #e1e4e8; height: .25em; padding: 0; margin: 24px 0; border: 0 }
.markdown-body blockquote { padding: 0 1em; color: #6a737d; border-left: .25em solid #dfe2e5 }
.markdown-body h1,.markdown-body h2 { padding-bottom: .3em; border-bottom: 1px solid #eaecef }
.markdown-body blockquote>:first-child { margin-top: 0 }
.markdown-body blockquote>:last-child { margin-bottom: 0 }
.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25 }
.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link { color: #1b1f23; vertical-align: middle; visibility: hidden }
.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor { text-decoration: none }
.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link { visibility: visible }
.markdown-body h6 { color: #6a737d }
.markdown-body ol,.markdown-body ul { padding-left: 2em }
.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul { margin-top: 0; margin-bottom: 0 }
.markdown-body li>p { margin-top: 16px }
.markdown-body li+li { margin-top: .25em }
.markdown-body dl { padding: 0 }
.markdown-body dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600 }
.markdown-body dl dd { padding: 0 16px; margin-bottom: 16px }
.markdown-body table { border-spacing: 0; border-collapse: collapse; display: block; width: 100%; overflow: auto }
.markdown-body table th { font-weight: 600 }
.markdown-body table td,.markdown-body table th { padding: 6px 13px; border: 1px solid #dfe2e5 }
.markdown-body table tr { background-color: #fff; border-top: 1px solid #c6cbd1 }
.markdown-body table tr:nth-child(2n) { background-color: #f6f8fa }
.markdown-body img { max-width: 100%; background-color: #fff }
.markdown-body code { padding: .2em 0; margin: 0; font-size: 85%; background-color: rgba(27,31,35,.05) }
.markdown-body code::after,.markdown-body code::before { letter-spacing: -.2em; content: "?" }
.markdown-body pre>code { padding: 0; margin: 0; font-size: 100%; white-space: pre; background: 0 0; border: 0 }
.markdown-body .highlight { margin-bottom: 16px }
.markdown-body .highlight pre { margin-bottom: 0 }
.markdown-body .highlight pre,.markdown-body pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: #f6f8fa }
.markdown-body pre code { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; background-color: transparent; border: 0 }
.markdown-body pre code::after,.markdown-body pre code::before { content: normal }
.markdown-body .full-commit .btn-outline:not(:disabled):hover { color: #005cc5; border-color: #005cc5 }
.markdown-body kbd { display: inline-block; padding: 3px 5px; font: 11px SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 10px; color: #444d56; vertical-align: middle; background-color: #fcfcfc; border: 1px solid #c6cbd1; border-bottom-color: #959da5 }
.node text,.noteText,div.mermaidTooltip { font-family: "trebuchet ms", verdana, arial }
.markdown-body :checked+.radio-label { position: relative; z-index: 1; border-color: #0366d6 }
.markdown-body .task-list-item+.task-list-item { margin-top: 3px }
.markdown-body .task-list-item input { margin: 0 .2em .25em -1.6em; vertical-align: middle }
.markdown-body hr { border-bottom-color: #eee }
.hljs { display: block; padding: .5em; color: #333; background: #f8f8f8 }
.diff .hljs-header,.hljs-comment { color: #998; font-style: italic }
.css .rule .hljs-keyword,.hljs-keyword,.hljs-request,.hljs-status,.hljs-subst,.hljs-winutils,.nginx .hljs-title { color: #333; font-weight: 700 }
.hljs-hexcolor,.hljs-number,.ruby .hljs-constant { color: teal }
.hljs-doctag,.hljs-string,.hljs-tag .hljs-value,.tex .hljs-formula { color: #d14 }
.hljs-id,.hljs-title,.scss .hljs-preprocessor { color: #900; font-weight: 700 }
.hljs-list .hljs-keyword,.hljs-subst { font-weight: 400 }
.hljs-class .hljs-title,.hljs-type,.tex .hljs-command,.vhdl .hljs-literal { color: #458; font-weight: 700 }
.django .hljs-tag .hljs-keyword,.hljs-rule .hljs-property,.hljs-tag,.hljs-tag .hljs-title { color: navy; font-weight: 400 }
.hljs-attribute,.hljs-name,.hljs-variable,.lisp .hljs-body { color: teal }
.hljs-regexp { color: #009926 }
.clojure .hljs-keyword,.hljs-prompt,.hljs-symbol,.lisp .hljs-keyword,.ruby .hljs-symbol .hljs-string,.scheme .hljs-keyword,.tex .hljs-special { color: #990073 }
.hljs-built_in { color: #0086b3 }
.hljs-cdata,.hljs-doctype,.hljs-pi,.hljs-pragma,.hljs-preprocessor,.hljs-shebang { color: #999; font-weight: 700 }
.hljs-deletion { background: #fdd }
.hljs-addition { background: #dfd }
.diff .hljs-change { background: #0086b3 }
.hljs-chunk { color: #aaa }
.mermaid .label { color: #333 }
.node circle,.node ellipse,.node polygon,.node rect { }
.edgePath .path { }
.edgeLabel { background-color: #e8e8e8 }
.cluster rect { }
.cluster text { }
.actor { }
text.actor { }
.actor-line { }
.messageLine0,.messageLine1 { }
#arrowhead { }
#crosshead path { }
.messageText { }
.labelBox { }
.labelText,.loopText { }
.loopLine { }
.note { }
.noteText { font-size: 14px }
.section { opacity: .2 }
.section0 { }
.section2 { }
.section1,.section3 { opacity: .2 }
.sectionTitle0,.sectionTitle1,.sectionTitle2,.sectionTitle3 { }
.sectionTitle { font-size: 11px }
.grid .tick { opacity: .3 }
.grid path { }
.today { }
.task { }
.taskText { font-size: 11px }
.taskTextOutsideRight { font-size: 11px }
.taskTextOutsideLeft { font-size: 11px }
.taskText0,.taskText1,.taskText2,.taskText3 { }
.task0,.task1,.task2,.task3 { }
.taskTextOutside0,.taskTextOutside1,.taskTextOutside2,.taskTextOutside3 { }
.active0,.active1,.active2,.active3 { }
.activeText0,.activeText1,.activeText2,.activeText3 { }
.done0,.done1,.done2,.done3 { }
.doneText0,.doneText1,.doneText2,.doneText3 { }
.crit0,.crit1,.crit2,.crit3 { }
.activeCrit0,.activeCrit1,.activeCrit2,.activeCrit3 { }
.doneCrit0,.doneCrit1,.doneCrit2,.doneCrit3 { cursor: pointer }
.activeCritText0,.activeCritText1,.activeCritText2,.activeCritText3,.doneCritText0,.doneCritText1,.doneCritText2,.doneCritText3 { }
.titleText { font-size: 18px }
.node text { font-size: 14px }
div.mermaidTooltip { position: absolute; text-align: center; max-width: 200px; padding: 2px; font-size: 12px; background: #ffffde; border: 1px solid #aa3; z-index: 100 }
body { margin: 0; padding: 0 }
.markdown-body { min-width: 256px; max-width: 978px; margin: 0 auto; padding: 20px; font-size: 14px }
.markdown-body h1 { font-size: 2.25em }
.markdown-body h2 { font-size: 1.75em }
.markdown-body h3 { font-size: 1.5em }
.markdown-body h4 { font-size: 1.25em }
.markdown-body h5,.markdown-body h6 { font-size: 1em }
div.mermaid { text-align: center }
hr.footnotes-sep { margin: 64px 0 32px; height: 1px }
.footnotes { font-size: 90%; padding-left: 16px }
li.footnote-item>p { margin: 8px 0 }
.danger,.info,.success,.warning { padding: 15px; margin-bottom: 20px; border: 1px solid transparent }
.danger>p:last-child,.info>p:last-child,.success>p:last-child,.warning>p:last-child { margin-bottom: 0 }
.success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6 }
.info { color: #31708f; background-color: #d9edf7; border-color: #bce8f1 }
.warning { color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc }
.danger { color: #a94442; background-color: #f2dede; border-color: #ebccd1 }
abbr[title] { cursor: help; border-bottom: 1px dotted #777 }
ul.table-of-contents li { margin: 4px 0 }
.markdown-body table td,.markdown-body table th { }
TableView
当tableview的style为grouped的时候,会出现每个section之间有间距。
官方解析:Link on iOS 11, all estimated heights default to UITableViewAutomaticDimension Headers, footers, and cells use self-sizing by default.
- 解决方案:
如果开发者不想用这个新特性,可以在代理方法里面设置具体的高度,然后设置
tableView.estimatedRowHeight = 0
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
TitleView
因为iOS11 的navbar的大标题和搜索栏的新特性,navbar的子视图发生了变化。 如果没有给出明确的长宽,就会出现Zero-size的出现,就是说titleview不见了,或者各种奇怪的事情出现。
- 解决方案:
- 给出指定的长宽,和子view设置好对应的约束。
- 或者重写intrinsicContentSize方法,设置成UILayoutFittingExpandedSize,让它自己自动扩展。
@available(iOS 6.0, *)
public let UIViewNoIntrinsicMetric: CGFloat
// Size To Fit
@available(iOS 6.0, *)
public let UILayoutFittingCompressedSize: CGSize
@available(iOS 6.0, *)
public let UILayoutFittingExpandedSize: CGSize
如果设置成扩展的话titleView和两边的item粘在一起了,所以需要做一下子视图的布局。
题外话: iOS6有一个API,systemLayoutSizeFitting,可以根据view的约束计算出对应的大小,具体可以看API文档。
Safe Area
这个主要影响用到mj的列表页面,和隐藏navbar的列表页面。
Safe Area是系统自己算的,系统会根据state bar的高度,navbar、tabbar是否透明(isTranslucent)。
每个view都有一个叫safeAreaInsets的属性(get only)。 如果开发者需要更改view的safe area 可以在controller设置additionalSafeAreaInsets去属性去弄。
例如:
带有navbar,和tabbar的页面。
controller.view.safeAreaInsets 为 UIEdgeInsets(top: 64.0, left: 0.0, bottom: 49.0, right: 0.0)
如果想改为(20,0,49,0)只需要做如下操作。
controller.view.additionalSafeAreaInsets = UIEdgeInsets(top: -44.0, left: 0.0, bottom: -49.0, right: 0.0)
其实无论设置成(-20000,0,0,0)也是最终得到的(20,0,49,0),还有就是无论设置bottom为-49还是其他的值,都无法抵消tabbar的高度,也就是说系统不允许我们去缩减bottom的值,可能是因为iPhoneX的底部虚拟home键。
view.safeAreaInsets是影响其子ScrollView的adjustedContentInset。 ScrollView会根据contentInsetAdjustmentBehavior属性去设置 adjustedContentInset。
public enum UIScrollViewContentInsetAdjustmentBehavior : Int {
case automatic // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable
case scrollableAxes // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES)
case never // contentInset is not adjusted
case always // contentInset is always adjusted by the scroll view‘s safeAreaInsets
}
- UIScrollViewContentInsetAdjustmentAutomatic:如果scrollview在一个automaticallyAdjustsScrollViewContentInset = YES的controller上,并且这个Controller包含在一个navigation controller中,这种情况下会设置在top & bottom上 adjustedContentInset = safeAreaInset + contentInset不管是否滚动。其他情况下与UIScrollViewContentInsetAdjustmentScrollableAxes相同
- UIScrollViewContentInsetAdjustmentScrollableAxes: 在可滚动方向上adjustedContentInset = safeAreaInset + contentInset,在不可滚动方向上adjustedContentInset = contentInset;依赖于scrollEnabled和alwaysBounceHorizontal / vertical = YES,scrollEnabled默认为yes,所以大多数情况下,计算方式还是adjustedContentInset = safeAreaInset + contentInset
- UIScrollViewContentInsetAdjustmentNever: adjustedContentInset = contentInset
- UIScrollViewContentInsetAdjustmentAlways: adjustedContentInset = safeAreaInset + contentInset
- 使用MJ的列表页的适配方案
if #available(iOS 11, *) {
t.contentInset.top += kTopBarHeight
t.contentInset.bottom += kHomeBarHeight // 如果列表底部没有任何toolbar的需要添加,为了适配iPhone X
t.contentInsetAdjustmentBehavior = .never
}
底层API命名改变
例如我使用一些第三方库的时候,它们有用到一些API如check_compile_time() 在iOS11里面的命名改变为__Check_Compile_Time()。
-解决方案:
找到对应的头文件,搜索旧的API一般都有说明的。
/*
* For time immemorial, Mac OS X has defined version of most of these macros without the __ prefix, which
* could collide with similarly named functions or macros in user code, including new functionality in
* Boost and the C++ standard library.
*
* macOS High Sierra and iOS 11 will now require that clients move to the new macros as defined above.
*
* If you would like to enable the macros for use within your own project, you can define the
* __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES macro via an Xcode Build Configuration.
* See "Add a build configuration (xcconfig) file" in Xcode Help.
*
* To aid users of these macros in converting their sources, the following tops script will convert usages
* of the old macros into the new equivalents. To do so, in Terminal go into the directory containing the
* sources to be converted and run this command.
*
find . -name ‘*.[c|cc|cp|cpp|m|mm|h]‘ -print0 | xargs -0 tops -verbose \
replace "check(<b args>)" with "__Check(<args>)" replace "check_noerr(<b args>)" with "__Check_noErr(<args>)" replace "check_noerr_string(<b args>)" with "__Check_noErr_String(<args>)" replace "check_string(<b args>)" with "__Check_String(<args>)" replace "require(<b args>)" with "__Require(<args>)" replace "require_action(<b args>)" with "__Require_Action(<args>)" replace "require_action_string(<b args>)" with "__Require_Action_String(<args>)" replace "require_noerr(<b args>)" with "__Require_noErr(<args>)" replace "require_noerr_action(<b args>)" with "__Require_noErr_Action(<args>)" replace "require_noerr_action_string(<b args>)" with "__Require_noErr_Action_String(<args>)" replace "require_noerr_string(<b args>)" with "__Require_noErr_String(<args>)" replace "require_string(<b args>)" with "__Require_String(<args>)" replace "verify(<b args>)" with "__Verify(<args>)" replace "verify_action(<b args>)" with "__Verify_Action(<args>)" replace "verify_noerr(<b args>)" with "__Verify_noErr(<args>)" replace "verify_noerr_action(<b args>)" with "__Verify_noErr_Action(<args>)" replace "verify_noerr_string(<b args>)" with "__Verify_noErr_String(<args>)" replace "verify_string(<b args>)" with "__Verify_String(<args>)" replace "ncheck(<b args>)" with "__nCheck(<args>)" replace "ncheck_string(<b args>)" with "__nCheck_String(<args>)" replace "nrequire(<b args>)" with "__nRequire(<args>)" replace "nrequire_action(<b args>)" with "__nRequire_Action(<args>)" replace "nrequire_action_quiet(<b args>)" with "__nRequire_Action_Quiet(<args>)" replace "nrequire_action_string(<b args>)" with "__nRequire_Action_String(<args>)" replace "nrequire_quiet(<b args>)" with "__nRequire_Quiet(<args>)" replace "nrequire_string(<b args>)" with "__nRequire_String(<args>)" replace "nverify(<b args>)" with "__nVerify(<args>)" replace "nverify_string(<b args>)" with "__nVerify_String(<args>)" replace "require_action_quiet(<b args>)" with "__Require_Action_Quiet(<args>)" replace "require_noerr_action_quiet(<b args>)" with "__Require_noErr_Action_Quiet(<args>)" replace "require_noerr_quiet(<b args>)" with "__Require_noErr_Quiet(<args>)" replace "require_quiet(<b args>)" with "__Require_Quiet(<args>)" replace "check_compile_time(<b args>)" with "__Check_Compile_Time(<args>)" replace "debug_string(<b args>)" with "__Debug_String(<args>)"
*
*/