Extended UIButton border is not initially drawn

This works public class MyButton : UIButton { public MyButton() : base(UIButtonType.RoundedRect) { } public override RectangleF Frame { get { return base.Frame; } set { var temp = TranslatesAutoresizingMaskIntoConstraints; TranslatesAutoresizingMaskIntoConstraints = false; var constraints = new [] { NSLayoutConstraint.Create(this, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1.0f, value.Width), NSLayoutConstraint.Create(this, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1.0f, value.Height) }; AddConstraints(constraints); … Read more

Write device platform specific code in Xamarin.Forms

This is a scenario which is easily resolved with dependency injection. Have a interface with the desired methods on your shared or PCL code, like: public interface IUserPreferences { void SetString(string key, string value); string GetString(string key); } Have a property on your App class of that interface: public class App { public static IUserPreferences … Read more

Is this a bug in MonoTouch GC?

This is an unfortunate side-effect of MonoTouch (who is garbage collected) having to live in a reference counted world (ObjectiveC). There are a few pieces of information required to be able to understand what’s going on: For every managed object (derived from NSObject), there is a corresponding native object. For custom managed classes (derived from … Read more

UIColor from Hex in Monotouch

I found some solutions for Objective C and none specifically for Monotouch I ended up developing an extension method based on the most popular solution for IOS: public static class UIColorExtensions { public static UIColor FromHex(this UIColor color,int hexValue) { return UIColor.FromRGB( (((float)((hexValue & 0xFF0000) >> 16))/255.0f), (((float)((hexValue & 0xFF00) >> 8))/255.0f), (((float)(hexValue & 0xFF))/255.0f) … Read more

Xamarin Auth Store Keychain not working after ios10 upgrade

I was digging through the link Pat sent in the comment: bugzilla.xamarin.com/show_bug.cgi?id=43514 And found a helpfull comment by Pavel Sich, he said: Just make sure you enable the keychain access in Entitlements and select the entitlements for Simulator (Debug) builds too. By default this is not set. In my xamarin solution, I double clicked the … Read more