iOS Label隨字自動變大效果
更新時間:2017年05月22日 10:22:41 作者:弦外雨
這篇文章主要為大家詳細(xì)介紹了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]; }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS 隱藏導(dǎo)航條和狀態(tài)欄實現(xiàn)方法
這篇文章主要介紹了 iOS隱藏導(dǎo)航條和狀態(tài)欄實現(xiàn)方法的相關(guān)資料,有時候根據(jù)需求開發(fā)APP 需要隱藏導(dǎo)航欄和狀態(tài)欄,這里提供了實現(xiàn)方法需要的朋友可以參考下2016-11-11理解iOS多線程應(yīng)用的開發(fā)以及線程的創(chuàng)建方法
這篇文章主要介紹了理解iOS多線程應(yīng)用的開發(fā)以及線程的創(chuàng)建方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-11-11IOS 播放系統(tǒng)提示音使用總結(jié)(AudioToolbox)
這篇文章主要介紹了IOS 播放系統(tǒng)提示音使用總結(jié)(AudioToolbox)的相關(guān)資料,需要的朋友可以參考下2017-05-05iOS開發(fā)之1行代碼實現(xiàn)緩存計算及清除緩存
這篇文章主要給大家介紹了關(guān)于iOS開發(fā)之1行代碼實現(xiàn)緩存計算及清除緩存的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05