//
// ViewController.m
// 重写
//
// Created by LTOVE on 15/11/10.
// Copyright (c) 2015年 LTOVE. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *Lable;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.Lable.text = @"把对方的你发的艾斯比撒旦吧撒旦吧深刻的成本ASF大神飞范德萨飞第三方大神飞第三方大神飞地方大神飞第三方大神飞第三方大神飞大神大神飞第三方大神范德萨飞大神发送到飞大神发送到飞大神飞速度 ";
self.Lable.adjustsFontSizeToFitWidth = YES;
// self.Lable.adjustsLetterSpacingToFitWidth= YES;
self.Lable.numberOfLines = 0;
[self adjest];
}
- (void)adjest
{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:self.Lable.text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.alignment = NSTextAlignmentLeft;
paragraphStyle.maximumLineHeight = 60;//设置最大行高
paragraphStyle.lineSpacing = 5;//设置行高
[paragraphStyle setFirstLineHeadIndent:80];//设置首行缩进的宽度
NSUInteger inde = self.Lable.text.length;
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, self.Lable.text.length)];
self.Lable.attributedText = attributedString;
[self.Lable sizeToFit];
}
@end
TextLable,TextView首行缩进问题
最新推荐文章于 2021-09-13 15:36:45 发布