swift 代码布局 改变tv的高


<p class="p1"><span class="s1"></span></p><p class="p1"><span class="s1"><span class="s1" style="background-color: rgb(240, 240, 240);">var</span><span class="s2" style="background-color: rgb(240, 240, 240);"> views:</span><span class="s3" style="background-color: rgb(240, 240, 240);">NSMutableDictionary</span><span class="s2" style="background-color: rgb(240, 240, 240);"> = </span><span class="s3" style="background-color: rgb(240, 240, 240);">NSMutableDictionary</span><span class="s2" style="background-color: rgb(240, 240, 240);">(</span><span style="background-color: rgb(240, 240, 240);">)</span>
</span></p><p class="p1"><span class="s1"><span style="background-color: rgb(240, 240, 240);">var shopCarConstrain = [AnyObject]!</span></span></p><p class="p1"><span class="s1">views</span><span class="s2">.</span><span class="s3">setValue</span><span class="s2">(</span><span class="s1">shopCarTv</span><span class="s2">, forKey: </span><span class="s4">"shopCarTv"</span><span class="s2">)</span></p><p class="p2"><span class="s5">shopCarTv</span><span class="s2">.</span><span class="s1">setTranslatesAutoresizingMaskIntoConstraints</span><span class="s2">(</span><span class="s6">false</span><span class="s2">)</span></p><p class="p2"><span class="s5" style="font-family: Arial, Helvetica, sans-serif;">shopCarConstraint</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;"> = </span><span class="s7" style="font-family: Arial, Helvetica, sans-serif;">NSLayoutConstraint</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">.</span><span class="s3" style="font-family: Arial, Helvetica, sans-serif;">constraintsWithVisualFormat</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">(</span><span class="s4" style="font-family: Arial, Helvetica, sans-serif;">"V:[shopCarTv(==</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">\</span><span class="s4" style="font-family: Arial, Helvetica, sans-serif;">(</span><span class="s5" style="font-family: Arial, Helvetica, sans-serif;">shopCarHeight</span><span class="s4" style="font-family: Arial, Helvetica, sans-serif;">))]-84-|"</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">, options: </span><span class="s6" style="font-family: Arial, Helvetica, sans-serif;">nil</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">, metrics: </span><span class="s6" style="font-family: Arial, Helvetica, sans-serif;">nil</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">, views: </span><span class="s5" style="font-family: Arial, Helvetica, sans-serif;">views</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;"> </span><span class="s6" style="font-family: Arial, Helvetica, sans-serif;">as</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;"> [</span><span class="s7" style="font-family: Arial, Helvetica, sans-serif;">NSObject</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;"> : </span><span class="s7" style="font-family: Arial, Helvetica, sans-serif;">AnyObject</span><span class="s1" style="font-family: Arial, Helvetica, sans-serif;">])</span></p><p class="p2"><span class="s1" style="font-family: Arial, Helvetica, sans-serif;"></span></p><p class="p1"><span class="s1">self</span><span class="s2">.</span><span class="s3">view</span><span class="s2">.</span><span class="s4">addConstraints</span><span class="s2">(</span><span class="s5">shopCarConstraint</span><span class="s2">)</span></p>
<p class="p2"><span class="s5"></span></p>

 

Y轴居中

timeTvConstraint = NSLayoutConstraint.constraintsWithVisualFormat("V:[timeTv(==\(timeTvHeight))]", options: NSLayoutFormatOptions.AlignAllCenterY, metrics: nil, views: views as [NSObject : AnyObject])
<p class="p1"><span class="s1"> </span><span class="s2">self</span><span class="s1">.</span><span class="s3">view</span><span class="s1">.</span><span class="s4">addConstraints</span><span class="s1">(</span><span class="s5">timeTvConstraint</span><span class="s1">)</span></p>







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值