CGAffineTransform在推动另一个控制器时恢复

时间:2014-05-12 10:12:22

标签: ios xcode cgaffinetransform

我必须在两个UIButton之间放置一个垂直分隔符。所以我创建了一个高度为1像素的UIView,并为其应用了CGAffineTransform。这是代码:

 _verticalSeperator = [[UIView alloc]init];
    [_verticalSeperator setTranslatesAutoresizingMaskIntoConstraints:NO];
    [_verticalSeperator setBackgroundColor:[UIColor blackColor]];
    [bottomView addSubview:_verticalSeperator];
// 1 pixel height
    [bottomView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_verticalSeperator(1)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_verticalSeperator)]];
// 40 pixels width
     [bottomView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[_verticalSeperator(40)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_verticalSeperator)]];
// centering the separator
    [bottomView addConstraint:[NSLayoutConstraint constraintWithItem:_verticalSeperator attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:bottomView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
    [bottomView addConstraint:[NSLayoutConstraint constraintWithItem:_verticalSeperator attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:bottomView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];

// applying the transform
_verticalSeperator.transform = CGAffineTransformMakeRotation(M_PI/2);

问题是当我按下一个新控制器时,转换会重置。它不再处于旋转状态。我尝试在viewWillAppear:(BOOL)animated中再次应用转换,以便当我弹回到此控制器时它再次旋转但它没有效果。

如何将分隔符保持在永久旋转状态?

如果已经提出这个问题,我很抱歉,但我无法找到。

0 个答案:

没有答案