iOS 中如何设置UITextView的字体样式

比如我想把字体设置为空心的 比如类似这样的图片描述

在线等

阅读 7.8k
2 个回答

你确定这不是粗体,或者其他字体??

    NSArray *array = [UIFont  familyNames];
    NSLog(@"%@",array);

    UITextField *textedd = [[UITextField alloc] initWithFrame:CM(15, 350, Screen_Width - 30, 40)];
    textedd.font = [UIFont fontWithName:@"Party LET" size:20];
    textedd.placeholder = @"dfsdfdf";
    textedd.textColor = BlackColor;
    textedd.backgroundColor = WhiteColor;
    [self.view addSubview:textedd];

效果
你设置textfiled的font属性,placeholder也会跟着变化的。

首先你这个还是 UITextField 比较适用,
然后你就设置一下背景颜色和 placeHolder就可以了
边框圆角通过layer.corderRadius修改
大致如下吧:

  _tv.layer.cornerRadius = 15.0;
  _tv.backgroundColor = [UIColor grayColor];
  NSDictionary *attributes = @{ NSForegroundColorAttributeName : [UIColor whiteColor] };
  _tv.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"搜索神马" attributes:attributes];

PS:这个方式是ios 6.0+ 才可以的,因为attributedString的原因

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题