来源:蜘蛛抓取(WebSpider)
时间:2016-04-04 09:06
标签:
uilabel顶端对齐
iPhone开发之让 UILabel 垂直方向顶端对齐
[来源]& &&&[编辑]&达内&&&[时间]
UILabel 里放入多行文字,会发现 label 默认居中对齐,很不符合左对齐的传统习惯,下面这段 CocoaChina 版主“angellixf”分享的代码可以让 UILabel 以垂直方向顶端对齐,也就是我们常说的左对齐或右对齐
UILabel 里放入多行文字,会发现 label 默认居中对齐,很不符合左对齐的传统习惯,下面这段 CocoaChina 版主&angellixf&分享的代码可以让 UILabel 以垂直方向顶端对齐,也就是我们常说的左对齐或右对齐
// VerticallyAlignedLabel.h
#import
typedef enum VerticalAlignment {
VerticalAlignmentTop,
VerticalAlignmentMiddle,
VerticalAlignmentBottom,
} VerticalA
@interface VerticallyAlignedLabel : UILabel {
@private
VerticalAlignment verticalAlignment_;
@property (nonatomic, assign) VerticalAlignment verticalA
// VerticallyAlignedLabel.m
#import &VerticallyAlignedLabel.h&
@implementation VerticallyAlignedLabel
@synthesize verticalAlignment = verticalAlignment_;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.verticalAlignment = VerticalAlignmentM
- (void)setVerticalAlignment:(VerticalAlignment)verticalAlignment {
verticalAlignment_ = verticalA
[self setNeedsDisplay];
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
switch (self.verticalAlignment) {
case VerticalAlignmentTop:
textRect.origin.y = bounds.origin.y;
case VerticalAlignmentBottom:
textRect.origin.y = bounds.origin.y + bounds.size.height - textRect.size.
case VerticalAlignmentMiddle:
// Fall through.
default:
textRect.origin.y = bounds.origin.y + (bounds.size.height - textRect.size.height) / 2.0;
return textR
-(void)drawTextInRect:(CGRect)requestedRect {
CGRect actualRect = [self textRectForBounds:requestedRect limitedToNumberOfLines:self.numberOfLines];
[super drawTextInRect:actualRect];在excel2007中如何设置单元格内容的垂直对齐方式_百度知道
在excel2007中如何设置单元格内容的垂直对齐方式
提问者采纳
默认情况单元格内容垂直向居齐用户根据需要设置顶端齐或底端齐操作:
其他类似问题
2人觉得有用
为您推荐:
垂直对齐的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁iphone UILabel 顶部对齐(top align) - Likwo - 博客园
&通常UILabel如果设置了numberOfLines = 0,就会在父控件的中间显示,如何才能让其顶部对齐,通过一下的方式就能实现top align&1、给myLabel标签内填充文本Label.text = @"文字内容;2、设置myLabel中希望的最大显示行数Label.numberOfLines = 0;(0表示无限行 )3、设置myLabel框架的最大尺寸Label.frame = CGRectMake(x, y, width, height);4、调用sizeToFit减小fame框架的尺寸,以使得myLabel框架的大小适应其中填充的内容这样就可以使得UILabel框架的大小适应其中填充的内容。wps页面设置中版式为什么没有垂直方向的居中可以选择_百度知道
wps页面设置中版式为什么没有垂直方向的居中可以选择
首先您打文档单击页面布局选项卡页面设置单击显示页面设置框按钮页面设置框单击版式选项卡页面区单击垂直齐式三角按钮列表选择顶端齐、居、两端齐或底端齐选项单击确定按钮即望采纳
其他类似问题
为您推荐:
wps的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁word对齐问题利用()工具,可以使表格中的内容垂直方向居中,水平方向靠单元格左侧对齐。 A.中部居中对齐
B.居中对齐 C.中部两端对齐 D.水平居中对齐
为您推荐:
扫描下载二维码