我可以使用哪些常数在自动布局默认水族空间? [英] What constant can I use for the default Aqua space in Autolayout?

查看:124
本文介绍了我可以使用哪些常数在自动布局默认水族空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据<一href=\"https://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AutolayoutPG/Articles/constraintFundamentals.html#//apple_ref/doc/uid/TP40010853-CH2-SW1\">Cocoa自动布局指南,我可以使用破折号,在视觉约束格式语言表示标准的水族空间:

According to the Cocoa Auto Layout Guide, I can use a dash in the visual constraint format language to "denote the standard Aqua space:"

[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[a]-[b]"
                                                             options:0
                                                             metrics:nil
                                                               views:viewDict]];

不过,我似乎无法找到一个 NSLayout ... 常量或方法,可以让我做同样的事情,如果我建立一个约束条件的没有的使用可视化格式语言:

However, I can't seem to find an NSLayout... constant or method that allows me to do the same thing if I'm building a constraint without using the visual format language:

[self addConstraint:[NSLayoutConstraint constraintWithItem:a
                                                 attribute:NSLayoutAttributeTrailing
                                                 relatedBy:NSLayoutRelationEqual
                                                    toItem:b
                                                 attribute:NSLayoutAttributeLeading
                                                multiplier:1.0f
                                                  constant:<# ??? #>]];

有没有一个恒定的(或其它值或方法),我可以用在这种情况下定义水族空间?

Is there a constant (or another value or method) that I can use to define the Aqua space in such a situation?

推荐答案

我已经找到了标准水族空间是兄弟之间的意见8.0和20.0的景色,它的父之间。

I've found the "standard Aqua space" to be 8.0 between sibling views, and 20.0 between a view and its superview.

NSView* view = [NSView new] ;
NSLayoutConstraint* constraintWithStandardConstantBetweenSiblings = [NSLayoutConstraint constraintsWithVisualFormat:@"[view]-[view]"  options:0  metrics:nil  views:NSDictionaryOfVariableBindings(view) ] [0] ;
CGFloat standardConstantBetweenSiblings = constraintWithStandardConstantBetweenSiblings.constant ;    // 8.0

NSView* superview = [NSView new] ;
[superview addSubview:view] ;
NSLayoutConstraint* constraintWithStandardConstantBetweenSuperview = [NSLayoutConstraint constraintsWithVisualFormat:@"[view]-|"  options:0  metrics:nil  views:NSDictionaryOfVariableBindings(view) ] [0] ;
CGFloat standardConstantBetweenSuperview = constraintWithStandardConstantBetweenSuperview.constant ;    // 20.0

这篇关于我可以使用哪些常数在自动布局默认水族空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆