ios 7.1 的更高分段控制

Higher Segmented Control for ios 7.1

我正在使用此代码更改分段控件的高度。它适用于 8.0 和最新版本,但不适用于 7.1 等更低版本。你知道任何其他改变它的方法吗?谢谢!

NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:segmentedControlShortcuts
                                                              attribute:NSLayoutAttributeHeight
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:nil
                                                              attribute:NSLayoutAttributeNotAnAttribute
                                                             multiplier:1
                                                               constant:50];

这是我在 7.1 中收到的错误:

"2015-04-09 12:10:06.626 KMetrix[546:607] 无法同时满足约束条件。 可能至少以下列表中的约束之一是您不想要的。试试这个:(1)查看每个约束并尝试找出您不期望的; (2) 找到添加了不需要的约束或约束的代码并修复它。 (注意:如果您看到不理解的 NSAutoresizingMaskLayoutConstraints,请参阅 UIView 属性 translatesAutoresizingMaskIntoConstraints 的文档) ( "", “” )

将尝试通过打破约束来恢复

在 objc_exception_throw 上中断以在调试器中捕获它。 中列出的 UIView 的 UIConstraintBasedLayoutDebugging 类别中的方法也可能有帮助。"

试试这个。在 iOS7 和 iOS8 -

中测试
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.mySegmentCtrl
                                                              attribute:NSLayoutAttributeHeight
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:nil
                                                              attribute:NSLayoutAttributeNotAnAttribute
                                                             multiplier:1
                                                               constant:50];
[self.mySegmentCtrl addConstraint:constraint];

检查它在 iOS7 和 iOS8 中都有效的屏幕截图 -