Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
How to manage text size in segment control for different devices?

I am trying to create custom segment control using CollectionViewCell. So i can manage text size of the segment control in different devices. But it is not working properly in all the devices. I have taken one cell inside collection view and used sizeForItemAt delegate method to equally set the cells. There will be only 3 cells. That is shown in the image.

This is the code for sizeForItemAt

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    return CGSize(width: (collectionView.frame.width / 3), height: 50.0)
}

Here is the output that i am getting This is output in iPhone 8. Title is not properly visible

This is output in iPhone 12 Pro Max

so i am trying to find solution using which i can manage text size in all the devices and all cells can take equal spacing as well.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

lbl_name.adjustsFontSizeToFitWidth = true

try this

UILabel.appearance(whenContainedInInstancesOf: [UISegmentedControl.self]).adjustsFontSizeToFitWidth = true 
UILabel.appearance(whenContainedInInstancesOf: [UISegmentedControl.self]).minimumScaleFactor = 6.0
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda