<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>