[英]How to do text alignment in iOS 6.0 ?
I am using the below code to get text but i dont know how to do text alignment in iOS 6.0..So,Please someone Help me... 我正在使用以下代码获取文本,但我不知道如何在iOS 6.0中进行文本对齐。.所以,请有人帮助我...
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:16.0];
cell.textLabel.textColor=[UIColor colorWithRed:15.0/255.0 green:122.0/255.0 blue:202.0/255.0 alpha:1.0];
cell.textLabel.text=[titleArray objectAtIndex:indexPath.row];
finally after a lot of research i found the answer of my question... 经过大量研究,终于找到了问题的答案...
label5.textAlignment = NSTextAlignmentLeft;
tnx to all who helped me... 向所有帮助我的人致敬...
This is what you need to do in iOS Devices 这是您在iOS设备中需要执行的操作
cell.textLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.textAlignment = UITextAlignmentCenter;
If your are developing something for MAC, you should use: 如果您正在为MAC开发东西,则应使用:
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.textAlignment = NSTextAlignmentCenter;
Assign Alignment accordingly. 相应地分配对齐方式。
cell.textLabel.textAlignment=NSTextAlignmentLeft;//or whatever you want buddy
让我知道它是否有效...
You can use the following code: 您可以使用以下代码:
cell.textLabel.textAlignment = NSTextAlignmentCenter;
Hope this helps. 希望这可以帮助。
Please try with another label and add it to the cell: 请尝试使用其他标签并将其添加到单元格中:
Write the following code on top of the class: 在该类的顶部编写以下代码:
#ifdef __IPHONE_6_0
# define ALIGN_CENTER NSTextAlignmentCenter
#else
# define ALIGN_CENTER UITextAlignmentCenter
#endif
Then add a label: 然后添加标签:
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
label.text = @"This is a sample text";
label.textAlignment = ALIGN_CENTER;
[cell.contentView addSubview:label];
[label release];
Is it works? 可行吗?
try this man...let see working or not... 试试这个人...看看工作与否...
write below statement in your common file (for example constant.h) 在公共文件中写以下语句(例如constant.h)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
//then to check textalignment for ios 6 or ios 5 write below code .m file where you want to use
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
{
cell.textLabel.textAlignment=NSTextAlignmentLeft;
}
else
{
cell.textLabel.textAlignment = UITextAlignmentCenter;
}
try this ... 尝试这个 ...
Happy Coding!!!!! 快乐编码!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.