Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UIKit] Add Preferred Content Size Wrapper #15800

Merged
merged 7 commits into from
Aug 31, 2022
4 changes: 4 additions & 0 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,10 @@ interface UIApplication {
[Export ("preferredContentSizeCategory")]
NSString PreferredContentSizeCategory { get; }
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved

[iOS (7,0)]
[Wrap ("UIContentSizeCategoryExtensions.GetValue (SharedApplication.PreferredContentSizeCategory)")]
UIContentSizeCategory GetPreferredContentSizeCategory ();

[iOS (13,0), TV (13,0)]
[Export ("connectedScenes")]
NSSet<UIScene> ConnectedScenes { get; }
Expand Down
11 changes: 11 additions & 0 deletions tests/monotouch-test/UIKit/UIContentSizeCategoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ public void Compare ()
Assert.Throws<ArgumentException> (() => UIContentSizeCategoryExtensions.Compare (small, (UIContentSizeCategory)271828));
Assert.Throws<ArgumentException> (() => ((UIContentSizeCategory)1234).IsAccessibilityCategory ());
}

[Test]
public void GetPreferredContentSizeCategoryTest ()
{
var sizeNSString = UIApplication.SharedApplication.PreferredContentSizeCategory;
var sizeEnum = UIContentSizeCategoryExtensions.GetValue (sizeNSString);
var size = UIApplication.SharedApplication.GetPreferredContentSizeCategory ();
Assert.AreEqual (sizeEnum, size, "String");
var sizeReverse = size.GetConstant ();
Assert.AreEqual (sizeNSString, sizeReverse, "NSString");
}
}
}

Expand Down