Last active
April 25, 2019 18:01
-
-
Save felipeslongo/36d0f7afe2216fb7d8147149038c79ee to your computer and use it in GitHub Desktop.
Garante que o table header view vai ser redimensionado corretamente para encapsular a view atribuida
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UIKit; | |
namespace App.iOS.Extensions | |
{ | |
//https://stackoverflow.com/questions/5484493/changing-the-height-of-a-tableheaderview-hides-the-cells/5764819#5764819 | |
public static class UITableViewAtribuirTableHeaderView | |
{ | |
private static bool VersaoIosBugadaQueNaoAtualizaOTamanhoCorretamenteDoTableHeaderView => | |
!UIDevice.CurrentDevice.CheckSystemVersion(9, 0); | |
public static void AtribuirTableHeaderView(this UITableView @this, UIView view) | |
{ | |
if (VersaoIosBugadaQueNaoAtualizaOTamanhoCorretamenteDoTableHeaderView) | |
{ | |
AtribuiTableHeaderViewRespeitandoTamanhoDaViewAtribuida(@this, view); | |
return; | |
} | |
@this.TableHeaderView = view; | |
} | |
private static void AtribuiTableHeaderViewRespeitandoTamanhoDaViewAtribuida(UITableView tableView, UIView view) | |
{ | |
tableView.TableHeaderView = view; | |
view.SizeToFit(); | |
tableView.TableHeaderView = view; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment