Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using MonoTouch.Foundation;
- using MonoTouch.UIKit;
- using System.Drawing;
- namespace Tandlaegen {
- public class CustomCell: UITableViewCell {
- UILabel headingLabel, subheadingLabel;
- UIImageView imageView;
- public CustomCell (NSString cellId) : base (UITableViewCellStyle.Default, cellId)
- {
- SelectionStyle = UITableViewCellSelectionStyle.Gray;
- imageView = new UIImageView ();
- headingLabel = new UILabel () {
- Font = UIFont.FromName("Gill Sans", 16f),
- TextColor = UIColor.White,
- BackgroundColor = UIColor.Clear
- };
- subheadingLabel = new UILabel () {
- Font = UIFont.FromName("Gill Sans", 12f),
- TextColor = UIColor.White,
- TextAlignment = UITextAlignment.Center,
- BackgroundColor = UIColor.Clear,
- Lines = 0
- };
- headingLabel.Lines = 0;
- headingLabel.LineBreakMode = UILineBreakMode.CharacterWrap;
- headingLabel.TextAlignment = UITextAlignment.Left;
- headingLabel.SizeToFit ();
- subheadingLabel.Lines = 0;
- subheadingLabel.LineBreakMode = UILineBreakMode.CharacterWrap;
- subheadingLabel.TextAlignment = UITextAlignment.Left;
- subheadingLabel.SizeToFit ();
- ContentView.Add (subheadingLabel);
- ContentView.Add (headingLabel);
- ContentView.Add (imageView);
- }
- public void UpdateCell (string caption, string subtitle, UIImage image, int type)
- {
- imageView.Image = image;
- headingLabel.Text = caption;
- subheadingLabel.Text = subtitle;
- ContentView.BackgroundColor = UIColor.White;
- headingLabel.TextColor = UIColor.Black;
- subheadingLabel.TextColor = UIColor.Black;
- subheadingLabel.Hidden = true;
- imageView.Hidden = true;
- }
- public override void LayoutSubviews ()
- {
- base.LayoutSubviews ();
- imageView.Frame = new RectangleF(ContentView.Bounds.Width - 63, 5, 33, 33);
- headingLabel.Frame = new RectangleF(ContentView.Bounds.Width - (ContentView.Bounds.Width / 2), 5, ContentView.Bounds.Width - 10, 30);
- headingLabel.SizeToFit ();
- subheadingLabel.Frame = new RectangleF(10, 45, ContentView.Bounds.Width, 20);
- subheadingLabel.SizeToFit ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement