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

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

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

在线等


首先你这个还是 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的原因


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

    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也会跟着变化的。

【热门文章】
【热门文章】