【问题标题】:UITextView Background ColorUITextView 背景颜色
【发布时间】:2014-05-08 14:11:50
【问题描述】:

我正在尝试在 Xcode 5 中为 UITextView 获取带有黑色背景或透明背景的白色文本。这里的问题。但不再是了。这个我也看到了

UItextView.backgroundColor = [UIColor clearColor];

作为修复它的一种方法。但不知道把它放在哪里,如果它甚至是正确的。谢谢

【问题讨论】:

    标签: ios uitextview


    【解决方案1】:

    当然你可以通过编程来完成:

    UITextView *txt = [[[UITextView alloc] initWithFrame: CGRectMake(10, 10, 100, 60)] autorelease];
    [txt setBackgroundColor: [UIColor clearColor]];
    [txt setTextColor: [UIColor whiteColor]];
    

    但您也可以通过图形编辑器的属性检查器分别将属性颜色设置为“白色”和背景设置为“清除颜色”来完成此操作。

    这是带有自定义背景的结果:

    【讨论】:

    • 我在背景属性区域没有看到选择器,只有文本颜色
    • 找到了。不知道为什么我今天早上没有看到它。
    • 该面板有更多部分。文本颜色属性位于“文本视图”部分,“背景颜色”位于“视图”部分(包含从视图类继承的属性)。如果您单击每个部分的顶部区域,您将隐藏该部分,您必须再次单击才能重新打开它!
    【解决方案2】:

    您应该在初始化后写入/设置UITextView 的任何属性

    _myTextViewName.backgroundColor = [UIColor clearColor]; // set clear backGround color or set as you want
    _myTextViewName.textColor  = [UIColor whiteColor]; // set white text color or set as you want
    

    【讨论】:

      【解决方案3】:

      你可以试试这个

      UItextView *yourTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0 ,320, 50)];
      yourTextView.backgroundColor = [UIColor clearColor];
      yourTextView.textColor = [UIColor whiteColor];
      [self.view addSubView:yourTextView];
      

      【讨论】:

        【解决方案4】:

        对于迅捷:

        @IBOutlet weak var textField: UITextField!
        textField.backgroundColor = UIColor.clearColor()
        

        【讨论】:

        • 寻找 UITextView - 不是字段。
        猜你喜欢
        • 2023-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-04
        相关资源
        最近更新 更多