iOS Label隨字自動變大效果
更新時間:2017年05月22日 10:22:41 作者:弦外雨
這篇文章主要為大家詳細介紹了iOS Label隨字自動變大效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
一、效果圖。

二、工程圖。

三、代碼。
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多線程應用的開發(fā)以及線程的創(chuàng)建方法
這篇文章主要介紹了理解iOS多線程應用的開發(fā)以及線程的創(chuàng)建方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-11-11
IOS 播放系統(tǒng)提示音使用總結(AudioToolbox)
這篇文章主要介紹了IOS 播放系統(tǒng)提示音使用總結(AudioToolbox)的相關資料,需要的朋友可以參考下2017-05-05
iOS開發(fā)之1行代碼實現(xiàn)緩存計算及清除緩存
這篇文章主要給大家介紹了關于iOS開發(fā)之1行代碼實現(xiàn)緩存計算及清除緩存的相關資料,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2020-05-05

