To set a background color
and text color
to an EntryCell in xamarin.forms iOS
, you can use custom renderer:
[assembly: ExportRenderer(typeof(MyEntryCell), typeof(myEntryCelliOSCellRenderer))]
namespace App99.iOS
{
public class myEntryCelliOSCellRenderer : EntryCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var nativeCell = (EntryCell)item;
var cell = base.GetCell(nativeCell, reusableCell, tv);
((UITextField)cell.Subviews[0].Subviews[0]).TextColor = UIColor.Orange;
((UITextField)cell.Subviews[0].Subviews[0]).BackgroundColor = UIColor.Green;
return cell;
}
}
}
And use it in Xamarin.forms project:
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
TableView tableView = new TableView
{
Intent = TableIntent.Form,
Root = new TableRoot
{
new TableSection
{
new MyEntryCell
{
Label = "EntryCell:",
Placeholder = "Type Text Here",
}
}
}
};
this.Content = new StackLayout
{
Children =
{
tableView
}
};
}
}
public class MyEntryCell : EntryCell {
}