Created
August 6, 2012 09:30
-
-
Save nicwise/3272634 to your computer and use it in GitHub Desktop.
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
// in dialogviewcontroller.cs, line 370-ish | |
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) | |
{ | |
var section = Root.Sections [indexPath.Section]; | |
var element = section.Elements [indexPath.Row]; | |
var cell = element.GetCell (tableView); | |
return section.CustomizeCell(cell, indexPath); // <-- added this | |
} | |
// in elements.cs, around line 2300, in public class Section | |
public virtual UITableViewCell CustomizeCell(UITableViewCell cell, NSIndexPath indexPath) | |
{ | |
return cell; | |
} | |
// and my custom section! Obviously, you need the images, too. | |
using System; | |
using MonoTouch.Dialog; | |
using MonoTouch.UIKit; | |
using MicroAgent.Common; | |
using MicroAgent.Library.Database; | |
using System.Threading.Tasks; | |
using System.Drawing; | |
namespace MicroAgent.Library | |
{ | |
public class BTBackgroundImageSection : Section | |
{ | |
public BTBackgroundImageSection(string header) : base(header){} | |
public BTBackgroundImageSection(string header, string footer) : base(header, footer) {} | |
public BTBackgroundImageSection() : base(null, BaseDialogViewController.MakeEmptySectionFooter()) {} | |
public BTBackgroundImageSection(UIView header) : base(header) | |
{ | |
} | |
public BTBackgroundImageSection(UIView header, UIView footer) : base(header, footer) | |
{ | |
} | |
public override UITableViewCell CustomizeCell (UITableViewCell cell, MonoTouch.Foundation.NSIndexPath indexPath) | |
{ | |
var theCell = base.CustomizeCell (cell, indexPath); | |
if (!Util.IsIOS5OrBetter) return cell; | |
if (Count == 1) //use one with top and bottom rounded | |
{ | |
theCell.BackgroundView = new UIImageView(Resources.CellBackgroundFull.CreateResizableImage(new UIEdgeInsets(5,5,5,5))); | |
theCell.SelectedBackgroundView = new UIImageView(Resources.CellBackgroundFullActive); | |
} else if (indexPath.Row == 0) //top only | |
{ | |
theCell.BackgroundView = new UIImageView(Resources.CellBackgroundTop.CreateResizableImage(new UIEdgeInsets(5,5,2,5))); | |
theCell.SelectedBackgroundView = new UIImageView(Resources.CellBackgroundTopActive); | |
} else if (indexPath.Row+1 == this.Count) // bottom only | |
{ | |
theCell.BackgroundView = new UIImageView(Resources.CellBackgroundBottom.CreateResizableImage(new UIEdgeInsets(0,5,5,5))); | |
theCell.SelectedBackgroundView = new UIImageView(Resources.CellBackgroundBottomActive); | |
} else //anything in the middle | |
{ | |
theCell.BackgroundView = new UIImageView(Resources.CellBackgroundMiddle.CreateResizableImage(new UIEdgeInsets(2,5,2,5))); | |
theCell.SelectedBackgroundView = new UIImageView(Resources.CellBackgroundMiddleActive); | |
} | |
return theCell; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment