【问题标题】:Unable to set border for flat ui kit in xcode?无法在 xcode 中为平面 ui 套件设置边框?
【发布时间】:2015-01-29 22:21:49
【问题描述】:

我正在使用 https://github.com/Grouper/FlatUIKit 此处的 flatui 套件作为 xcode 中 ios 开发的附加组件。当我创建一个文本字段时,它无法将边框正确设置为 uicolor。我正在使用 github 页面上的教程中显示的内容,但它似乎不起作用。我设置属性的代码如下:

_NameField.font = [UIFont flatFontOfSize:16];
    _NameField.backgroundColor = [UIColor clearColor];
    _NameField.edgeInsets = UIEdgeInsetsMake(4.0f, 15.0f, 4.0f, 15.0f);
    _NameField.textFieldColor = [UIColor whiteColor];
    _NameField.borderColor = [UIColor turquoiseColor];
    _NameField.borderWidth = 20;
    _NameField.cornerRadius = 3.0f;

我已将文本字段设置为名为 _NameField 的插座,将插座类型更改为 FUITextField,并将情节提要上的类设置为 FUITextField。感谢您的帮助!

另外,我搜索了 github 下载中包含的示例,它没有实现 FUITextField 元素。

【问题讨论】:

    标签: ios objective-c flatui


    【解决方案1】:

    我查看了包的 FUITextField.m 文件并研究了它的工作原理。我在它声明的地方发现了一个错误:

    - (void)configureTextField {
        _flatBackgroundImage = [self textFieldImageWithColor:_textFieldColor borderColor:_borderColor borderWidth:0 cornerRadius:_cornerRadius];
        _flatHighlightedBackgroundImage = [self textFieldImageWithColor:_textFieldColor borderColor:_borderColor borderWidth:_borderWidth cornerRadius:_cornerRadius];
    
        [self setBackground:_flatBackgroundImage];
    }
    

    我注意到borderWidth 是如何设置为0 的。相反,我将其更改为_borderWidth,它起作用了! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      相关资源
      最近更新 更多