Bug 22625 - UITableView.Appearance is "missing" some properties such as TextColor
Summary: UITableView.Appearance is "missing" some properties such as TextColor
Status: NEW
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: 7.4.x
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-09-04 00:36 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2014-09-04 00:36 UTC (History)
1 user (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Brendan Zagaeski (Xamarin Team, assistant) 2014-09-04 00:36:22 UTC
`UITextView.Appearance` is "missing" some properties such as `TextColor`.

This is essentially the same issue as https://bugzilla.xamarin.com/show_bug.cgi?id=21221, but for `UITextView` instead of `UIScrollView`.

As discussed on bug 21221 (and bug 8342), the UIKit headers distributed by Apple [1] do not strictly adhere to the rule that properties that participate in the appearance proxy API should be tagged with the UI_APPEARANCE_SELECTOR [2].

> [1] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/

> [2] https://developer.apple.com/library/ios/recipes/UIAppearanceContainer_Protocol/Reference/Reference.html#//apple_ref/c/macro/UI_APPEARANCE_SELECTOR

The fact that none of the `UITextView` properties are tagged conflicts with the "Appearance of Text Views" section from the iOS Developer Library [3]. That article lists the following properties:
- font
- textColor
- textAlignment
- typingAttributes
- attributedText

And then says: "To customize the appearance of all text views in your app, use the appearance proxy (for example, [UITextView appearance])". 

> [3] https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UITextView.html#//apple_ref/doc/uid/TP40012857-UITextView-SW3

## Workaround

You can treat the appearance proxy as a full `UITextView` instead of a `UITextView.UITextViewAppearance` (see [4]). That way you'll be able to attempt to set any property that is part of `UITextView`. Just remember that not all of the properties from `UITextView` will necessarily be compatible with the appearance proxy!

> [4] http://stackoverflow.com/a/14531680/220643

Here's an example that sets a few properties on the appearance proxy. All the properties in this example seem to work on iOS 7.

> var appearance = new UITextView (UITextView.Appearance.Handle);
> appearance.Text = "Override text in all text views";
> appearance.TextColor = UIColor.Blue;
> appearance.Font = UIFont.BoldSystemFontOfSize(16);
> appearance.TextAlignment = UITextAlignment.Justified;
> appearance.TextContainerInset = new UIEdgeInsets(10, 10, 10, 10);

Note You need to log in before you can comment on or make changes to this bug.