記錄一個(gè)暫未解決的問題国旷。
一個(gè)tablevicecell 中包含的元素全部是UILabel碴裙,以現(xiàn)在的技術(shù)無法做到cell 自適應(yīng)高度沮趣,之前用的一套自適應(yīng)機(jī)制目前無法實(shí)現(xiàn)。咪啡。先挖坑首启,記錄下
Autolayout小結(jié)(二)
這邊文章有個(gè)思路,還沒有試撤摸。
Multiple UILabels inside a self sizing UITableViewCell
這個(gè)還沒有細(xì)看毅桃。
ios Content Hugging
- 2016/8/18
牽扯到幾個(gè)概念:
Content Compression Resistance
Content Hugging
英文意思褒纲。(囧RZ。英語渣的苦惱)
Content :內(nèi)容
Compression:壓縮
Resistance:抵抗钥飞、阻力
Hugging:擁抱參考:IOS開發(fā)之Autolayout——“Content Compression Resistance”和“Content Hugging”
“Content Compression Resistance Priority”莺掠,也叫內(nèi)容壓縮阻力優(yōu)先級(jí)(小名:別擠我),該優(yōu)先級(jí)越高读宙,則越晚輪到被壓縮彻秆。
“Content Hugging Priority”,也叫內(nèi)容緊靠優(yōu)先級(jí)(小名:別扯我)结闸,該優(yōu)先級(jí)越高唇兑,這越晚輪到被拉伸。參考:Cocoa Autolayout: content hugging vs content compression resistance priority
Quick summary of the concepts:
Hugging => content does not want to grow
Compression Resistance => content does not want to shrink
and an example:
Say you've got button like this:
[ Click Me ]
and you've pinned the edges to a larger superview with priority 500.
Then, if Hugging priority > 500 it'll look like this:
[Click Me]
If Hugging priority < 500 it'll look like this:
[ Click Me ]
If superview now shrinks then, if the Compression Resistance priority > 500, it'll look like this
[Click Me]
Else if Compression Resistance priority < 500, it could look like this:
[Cli..]
If it doesn't work like this then you've probably got some other constraints going on that are messing up your good work!
E.g. you could have it pinned to the superview with priority 1000. Or you could have a width priority. If so, this can be helpful:
Editor > Size to Fit Content
馬丹桦锄,因?yàn)檫@幾個(gè)英文單詞我又去搜索怎么背單詞去了扎附。老是犯這種毛病,不專注=嵋帕棉!
搞定!1恰香伴!
要點(diǎn)就是上面提到的兩個(gè)屬性。
“Content Compression Resistance Priority”具则,也叫內(nèi)容壓縮阻力優(yōu)先級(jí)(小名:別擠我)即纲,該優(yōu)先級(jí)越高,則越晚輪到被壓縮博肋。
“Content Hugging Priority”低斋,也叫內(nèi)容緊靠優(yōu)先級(jí)(小名:別扯我),該優(yōu)先級(jí)越高匪凡,這越晚輪到被拉伸膊畴。
稍后忙完這段時(shí)間 整理出一片文章出來。