static const CGfloat MAX_Font_SIZE = 16.0;static const CGfloat MIN_Font_SIZE = 4.0;@interface MyVIEwController ()// I haven't dealt with Storyboard / Interface builder in years,// so this is my guess on how you link the GUI to code@property(nonatomic,strong) IBOutlet UITextVIEw* textVIEw;- (voID)textDIDChange:(UITextVIEw*)textVIEw;@end@implementation MyVIEwController- (voID)vIEwDIDLoad { [super vIEwDIDLoad]; [self.textVIEw addTarget:self action:@selector(textDIDChange:) forControlEvents:UIControlEventEditingChanged]; self.textVIEw.Font = [UIFont systemFontOfSize:MAX_Font_SIZE];}- (voID)textDIDChange:(UITextVIEw*)textVIEw{ // You need to adjust this sizing algorithm to your needs. // The following is oversimpListic. self.textVIEw.Font = [UIFont systemFontOfSize:MAX( MAX_Font_SIZE - textVIEw.text.length,MIN_Font_SIZE )];}@end总结
以上是内存溢出为你收集整理的ios – 更改字体大小以适合UITextView全部内容,希望文章能够帮你解决ios – 更改字体大小以适合UITextView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)