一,效果圖。二,工程圖。三,代碼。RootViewController.m#import "RootViewController.h"@interface RootViewController ()@end@implementation RootViewController- (id)initWit...
一,效果圖。
二,工程圖。
三,代碼。
RootViewController.m
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//初始化textView
[self addTextView];
}
#pragma -mark -functions
-(void)addTextView
{
UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 100, 320, 200)];
textView.backgroundColor = [UIColor redColor];
textView.textAlignment=NSTextAlignmentLeft;
NSString * str = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"腦筋急轉彎" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
textView.text = str;
[self.view addSubview:textView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}