Is it possible to set Appearance.LayoutMargins? RRS feed

  • Question

  • User48232 posted

    I've discovered a way how to globally modify UITableView separator insets in iOS8 and it works perfectly with Objective-C but I can't find how to do that with Xamarin.IOS.

    [[UITableView appearance] setLayoutMargins:UIEdgeInsetsZero];
    [[UITableViewCell appearance] setLayoutMargins:UIEdgeInsetsZero];

    I do see UITableViewCell.Appearance but only with BackgroundColor and TintColor. The same with UITableView - I don't see LayoutMargins property over there.

    Any ideas why?

    Sunday, May 10, 2015 9:04 PM


  • User181 posted

    According to the documentation only methods that are marked in Objective-C with UI_APPEARANCE_SELECTOR should be used with the appearance API, and therefore Xamarin only created bindings for those methods. The way the appearance API works in Objective-C lets you set any property on the appearance proxy, even if it doesn't make any sense. Sometimes that actually works even if it's not documented, but sometimes it only works in certain circumstances.

    This particular method is not marked with the UI_APPEARANCE_SELECTOR tag, and therefore it may not work always so Xamarin didn't create a binding for it.

    My suggestion is to use a common base class to control this app-wide instead of the appearance API.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, May 10, 2015 9:59 PM