material-components-ios icon indicating copy to clipboard operation
material-components-ios copied to clipboard

How to decrease the MDCTextField height

Open SwiftSamples opened this issue 4 years ago • 3 comments

For usage questions: ask on Stack Overflow.

A clear and concise description of what the bug is.

Reproduction steps

Steps to reproduce the behavior:

i have installed pod 'MaterialComponents/TextFields' pod in my project

and i have added textfield in my storyboard with height 30 and i have added this code in my swift file

 import MaterialComponents

class PageContentViewController: UIViewController {

@IBOutlet weak var serviceTitleTextField: MDCTextField!

private var titleTextfieldeController: MDCTextInputControllerOutlined?

override func viewDidLoad() {
super.viewDidLoad()  

titleTextfieldeController = MDCTextInputControllerOutlined(textInput: serviceTitleTextField)
titleTextfieldeController?.floatingPlaceholderActiveColor = .darkGray

}

so here i am getting big height for textfield in output

I want 30 height textfield.. how.. please do help

Screenshot 2021-08-19 at 11 36 51 PM

  1. Go to '...'
  2. Tap on '....'

Expected behavior

A clear and concise description of what you expected to happen.

Actual behavior

A clear and concise description of what actually happened. Include screenshots or gifs where possible.

Platform (please complete the following information)

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]

Additional context

Add any other context about the problem here.

SwiftSamples avatar Aug 19 '21 18:08 SwiftSamples

Try with preferredContainerHeight or verticalDensity.

ibeleliev avatar Sep 10 '21 13:09 ibeleliev

Try with preferredContainerHeight or verticalDensity.

how to use preferredContainerHeight or verticalDensity. could you explain

SwiftSamples avatar Oct 05 '21 17:10 SwiftSamples

preferredContainerHeight and verticalDensity are properties on TextControls text fields, not MDCTextField. To use those properties you'd need to use this component: https://github.com/material-components/material-components-ios/tree/develop/components/TextControls As opposed to this one: https://github.com/material-components/material-components-ios/tree/develop/components/TextFields

andrewoverton avatar Oct 06 '21 14:10 andrewoverton