首页 > 移动平台 > 详细

【代码笔记】iOS-Label随字自动变大

时间:2017-05-22 09:14:23      阅读:307      评论:0      收藏:0      [点我收藏+]

一,效果图。

技术分享

二,工程图。

技术分享

三, 代码。

RootViewController.h

技术分享
#import <UIKit/UIKit.h>
//添加HPGrowingTextView头文件
#import "HPGrowingTextView.h"

@interface RootViewController : UIViewController
<HPGrowingTextViewDelegate>
{
    HPGrowingTextView *textView;
}

@end
技术分享

 

RootViewController.m

技术分享
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
  
    
    textView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(10, 100, 240, 40)];
    textView.isScrollable = NO;
    textView.contentInset = UIEdgeInsetsMake(0, 5, 0, 5);
    textView.minNumberOfLines = 1;
    textView.maxNumberOfLines = 6;
    // you can also set the maximum height in points with maxHeight
    // textView.maxHeight = 200.0f;
    textView.returnKeyType = UIReturnKeyGo; //just as an example
    textView.font = [UIFont systemFontOfSize:15.0f];
    textView.delegate = self;
    textView.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(5, 0, 5, 0);
    textView.backgroundColor = [UIColor greenColor];
    textView.placeholder = @"Type to see the textView grow!";
    [self.view addSubview:textView];
    
    
    
    
}
技术分享

 

【代码笔记】iOS-Label随字自动变大

原文:http://www.cnblogs.com/yang-guang-girl/p/6887925.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!