ios - 是否可以覆盖 MDCTextInputControllerFilled 的 borderView 框架?

标签 ios swift material-components material-components-ios

我的设计尽可能类似于 MDCTextField(带有 Controller MDCTextInputControllerFilled)。我检查了组件,我认为我应该覆盖 Controller 的组件,但为什么呢?

如果我走错了路,你能帮我解决这个问题吗?

我的测试代码如下

tfc1?.placeholderText = "Test"
tfc1?.borderFillColor = UIColor.brown.withAlphaComponent(1)
if let f = tfc1?.textInput?.borderView?.frame {
    tfc1?.textInput?.borderView?.frame = CGRect(
        x: f.origin.x,
        y: f.origin.y + 25,
        width: f.width,
         height: f.height + 25
    )
}

最佳答案

感谢您的耐心等待。我假设只有一行很重要,这使得这更简单。

看起来您想要一个位于比该字段高 25 英寸的容器中居中的文本字段。

我会继承 MDCTextInputControllerFilled。在子类中覆盖 textInsets:。这是 Objective-C 的开始:

- (UIEdgeInsets)textInsets:(UIEdgeInsets)defaultInsets {
  UIEdgeInsets textInsets = [super textInsets:defaultInsets];
  textInsets.top = 12.5;
  textInsets.bottom = 12.5;

  return textInsets;
}

不要直接调整边框 View 的框架。它从很多来源获取信息。对您来说重要的是插图。

关于ios - 是否可以覆盖 MDCTextInputControllerFilled 的 borderView 框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50228552/

相关文章:

ios - 如何确定 NSDate 是否是工作日?

ios - 嵌入 pods 框架 - Command/bin/sh 失败,退出代码为 1

swift - 在 Swift 4 中解码结构中的字符串或 int 值将返回字符串 ("1")

ios - 无法将类型 '()' 的值转换为预期的参数类型 'String'

android - 自定义后 Material 复选框样式

html - 如何允许在 iOS 上上传 PDF 文件?

ios - 仅 Storyboard 和 iPhone 6 横向

android - 我需要添加什么依赖项才能使用 com.google.android.material.slider.Slider

android - 如何在android中创建自定义圆卡 View

ios - MKAnnotation 未声明