How to position a child view relative to containing view size?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to be able to position my child view 25% the size of the super view from the top. NSLayoutConstraint *topPositionConstraint = [NSLayoutConstraint constraintWithItem:_containerView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:_childView attribute:NSLayoutAttributeHeight multiplier:0.25f constant:0.0f]; However, right now I'm getting the following exception: 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Invalid