Skip to content

Instantly share code, notes, and snippets.

@nukedbit
Created December 12, 2015 00:04
Show Gist options
  • Save nukedbit/298d71af591c4e39c39b to your computer and use it in GitHub Desktop.
Save nukedbit/298d71af591c4e39c39b to your computer and use it in GitHub Desktop.
Xamarin Forms ListView Custom selection color
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using UIKit;
using CoreGraphics;
[assembly: ExportRenderer (typeof(MyApp.MenuListViewCell), typeof(MyApp.iOS.MenuListViewCellRenderer))]
namespace MyApp.iOS {
public class MenuListViewCellRenderer : ViewCellRenderer {
public override UITableViewCell GetCell (Cell item, UITableViewCell reusableCell, UITableView tv) {
var cell = base.GetCell (item, reusableCell, tv);
cell.SelectionStyle = UITableViewCellSelectionStyle.Default;
cell.SelectedBackgroundView = new UIView (cell.Bounds) {
BackgroundColor = Color.FromRgba(0,0,0,100).ToUIColor()
};
return cell;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment