是否可以水平旋转UILabel绕轴?翻转时钟之类的东西?
是。试试这个:
label.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2)
您可以添加UILabel子类,并实现翻转动画,如下所示:
@implementation FlippingLabel
- (void)flipToAlphabet:(NSString *)alphabet {
[UIView transitionWithView:self
duration:0.3
options:UIViewAnimationOptionTransitionFlipFromTop
animations: ^{
self.text = [self.text nextCharacterInSequence];
}
completion: ^(BOOL finished) {
if (![self.text isEqualToString:alphabet]) {
if (![[self.text nextCharacterInSequence] isEqualToString:@"-"]) {
[self flipToAlphabet:alphabet];
}
}
}];
}
我在之前的一个项目中做过类似的事情。 https://github.com/mehul90/Flipper