【问题标题】:How to zoom TextField when focused?聚焦时如何缩放TextField?
【发布时间】:2015-08-04 06:48:37
【问题描述】:

我想在获得焦点时放大文本字段。如果键盘出现或消失,我知道如何向上或向下移动文本字段。但是,不知道如何放大或缩小文本字段。

【问题讨论】:

  • 像 iPhone 上的浏览​​器一样吗?

标签: ios objective-c iphone xcode ipad


【解决方案1】:

为 UITextField 设置代理后。试试这个,希望对你有帮助。

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    textField.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
        textField.transform = CGAffineTransformMakeScale(1.0, 1.0);
}

【讨论】:

    【解决方案2】:

    您可以使用 contentScaleFactor 放大。 你可以参考这个answer做进一步的解释

    【讨论】:

      猜你喜欢
      • 2020-08-28
      • 1970-01-01
      • 2016-05-30
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      • 2018-02-08
      • 1970-01-01
      • 2020-02-13
      相关资源
      最近更新 更多