You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否重写MDCTextInputControllerFilled的borderView的frame?求设计适配方案

关于MDCTextField搭配MDCTextInputControllerFilled的自定义实现疑问

最近我有个设计需求,想要做一个和**MDCTextField(搭配MDCTextInputControllerFilled控制器)**外观、行为尽可能相似的自定义输入框。我初步想的是重写这个控制器的相关方法来实现,但拿不准这个思路到底对不对;如果方向错了,麻烦各位大佬帮忙指点一下怎么解决这个问题。

我目前写的测试代码片段是这样的:

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.size.width,
        height: f.size.height
    )
}

内容的提问来源于stack exchange,提问作者Utku

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:05:29