zoukankan      html  css  js  c++  java
  • UITextView IOS开发

    在.h文件中声明:

    @interface ProtocolViewController :UIViewController<UITextViewDelegate>
    {
        
        UITextView *textView;
        
    }
    @property (nonatomic,retain)UITextView *textView;
    @end

    UITextView *textView = [[UITextViewalloc]initWithFrame:CGRectMake(0, 275, 320, 224)];

    在.m中初始化:

    self.textView=[[[UITextView alloc] initWithFrame:self.view.frame] autorelease]; //初始化大小并自动释放 
    self.textView.textColor = [UIColor blackColor];//设置textview里面的字体颜色 
    self.textView.font = [UIFont fontWithName:@"Arial"size:18.0];//设置字体名字和字体大小
    self.textView.delegate = self;//设置它的委托方法 
    self.textView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色               
    self.textView.text = @"abcdefghi\nkjhk\nhkjhkjhksaejodslkae\nnfdkshekhfkdsae\nfdhskejhkfhskejh\ngfdhsgaejhgfjhdsgaejhgfjhdsgaejhgfdjsagejhgfhjsagejhgfdsjahgejhfgdsjha";//设置它显示的内容
    self.textView.returnKeyType = UIReturnKeyDefault;//返回键的类型
    self.textView.keyboardType = UIKeyboardTypeDefault;//键盘类型
    self.textView.scrollEnabled = YES;//是否可以拖动           
    self.textView.editable =NO;//禁止编辑
    self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度           
    [self.view addSubview: self.textView];//加入到整个页面中
       UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 275, 320, 224)];
        [textView setText:@"开封古称东京、汴京(亦有大梁、汴梁之称),简称汴,有“十朝古都”、“七朝都会”之称。开封是清明上河图的原创地,有“东京梦华”之美誉,开封是中国优秀旅游城市、全国双拥模范城、全国创建文明城市工作先进城市,也是河南省中原城市群和沿黄“三点一线”黄金旅游线路三大中心城市之一。开封是世界上唯一一座城市中轴线从未变动的都城,城摞城遗址在世界考古史和都城史上是绝无仅有的。北宋东京开封是当时世界最繁华、面积最大、人口最多的大都市。现辖尉氏、杞、通许、兰考、开封五县和鼓楼、龙亭、禹王台、顺河回族、金明五区。"];
        textView.font = [UIFont fontWithName:@"Arial"size:14];//设置字体名字和字体大小
        textView.editable = NO;
        [myscrollview addSubview:textView];
  • 相关阅读:
    在centos7上安装ClamAV杀毒,并杀毒(centos随机英文10字母)成功
    在centos7上安装Jenkins
    Spring cache简单使用guava cache
    Spring resource bundle多语言,单引号format异常
    如何优化coding
    IIS配置中出现HRESULT:0X80070020错误
    如何解决:对应的服务器 tls 为 tls 1.0,小程序要求的TLS版本必须大于等于1.2问题
    微信小程序--后台交互/wx.request({})方法/渲染页面方法 解析
    微信小程序页面带参数跳转及接收参数内容navigator
    微信小程序阿里云服务器https搭建
  • 原文地址:https://www.cnblogs.com/jxyZ/p/3031288.html
Copyright © 2011-2022 走看看