using System;
using CoreGraphics;

using Foundation;
using UIKit;

namespace TextKitDemo
{
	public partial class CollectionViewCell : UICollectionViewCell
	{
		public CollectionViewCell (IntPtr handle) : base (handle)
		{
			BackgroundColor = UIColor.DarkGray;
			Layer.CornerRadius = 5;

			UIApplication.Notifications.ObserveContentSizeCategoryChanged (delegate {
				CalculateAndSetFonts ();
			});
		}

		public void FormatCell (DemoModel demo)
		{
			containerView.Layer.CornerRadius = 2;
			labelView.Text = demo.Title;
			textView.AttributedText = demo.GetAttributedText ();

			CalculateAndSetFonts ();
		}

		void CalculateAndSetFonts ()
		{
			const float cellTitleTextScaleFactor = 0.85f;
			const float cellBodyTextScaleFactor = 0.7f;

			UIFont cellTitleFont = Font.GetPreferredFont (labelView.Font.FontDescriptor.TextStyle, cellTitleTextScaleFactor);
			UIFont cellBodyFont = Font.GetPreferredFont (textView.Font.FontDescriptor.TextStyle, cellBodyTextScaleFactor);

			labelView.Font = cellTitleFont;
			textView.Font = cellBodyFont;
		}
	}
}


using System;
using CoreGraphics;

using Foundation;
using UIKit;

namespace TextKitDemo
{
	public partial class CollectionViewCell : UICollectionViewCell
	{
		public CollectionViewCell (IntPtr handle) : base (handle)
		{
			Initialize ();
		}

		[Export ("initWithCoder:")]
		public CollectionViewCell (NSCoder coder) : base (coder)
		{
			Initialize ();
		}

		void Initialize ()
		{
			BackgroundColor = UIColor.DarkGray;
			Layer.CornerRadius = 5;

			UIApplication.Notifications.ObserveContentSizeCategoryChanged (delegate {
				CalculateAndSetFonts ();
			});
		}

		public void FormatCell (DemoModel demo)
		{
			containerView.Layer.CornerRadius = 2;
			labelView.Text = demo.Title;
			textView.AttributedText = demo.GetAttributedText ();

			CalculateAndSetFonts ();
		}

		void CalculateAndSetFonts ()
		{
			const float cellTitleTextScaleFactor = 0.85f;
			const float cellBodyTextScaleFactor = 0.7f;

			UIFont cellTitleFont = Font.GetPreferredFont (labelView.Font.FontDescriptor.TextStyle, cellTitleTextScaleFactor);
			UIFont cellBodyFont = Font.GetPreferredFont (textView.Font.FontDescriptor.TextStyle, cellBodyTextScaleFactor);

			labelView.Font = cellTitleFont;
			textView.Font = cellBodyFont;
		}
	}
}


Fix ctor, we must use initWithCoder when loading from a storyboard
[TextKitDemo] Fix ctor, we must use initWithCoder when loading from a storyboard

initWithCoder: is the designated initializer for views built from the storyboard
since we are not creating the Cell programatically by calling
RegisterClassForCell we must export initWithCoder: ctor to unmanaged world so
when it needs to create a new cell it calls into our managed initWithCoder:
and do the initialization we want.
