jdl*_*jdl 68 objective-c rotation uibutton uilabel ios
你怎么能为UIButton
和旋转文字UILabel
?90度,180度.
Gyp*_*psa 168
[*yourlabelname* setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
Run Code Online (Sandbox Code Playgroud)
旋转图像
透视图像
Div*_*ert 33
试试这个:
lbl.transform= CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(270));
Run Code Online (Sandbox Code Playgroud)
And*_*y S 11
我想提供另一种回应.
UILabel
您可以通过从子类中获取子类来覆盖标签内的文本,而不是旋转它.如果您使用的是Interface Builder,则可以指定此子类,而不是Identity Inspector的Custom Class属性.这将允许您使用XIB构建UI,而不是以编程方式创建标签.唯一需要注意的是Interface Builder中的文本将水平显示.但是,它将在应用程序本身中垂直呈现.UILabel
drawRect
UILabel
#import "RotatedLabel.h"
@implementation RotatedLabel
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextRotateCTM(context, -(M_PI/2));
UIFont* systemFont17 = [UIFont systemFontOfSize:17.0];
CGSize textSize = [self.text sizeWithFont:systemFont17];
CGFloat middle = (self.bounds.size.width - textSize.height) / 2;
[self.text drawAtPoint:CGPointMake(-self.bounds.size.height, middle) withFont:systemFont17];
CGContextRestoreGState(context);
}
@end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
43537 次 |
最近记录: |