2012-10-27 70 views

回答

1

可以使用MonoTouch UIResponder.SetValueForKey(key,value)調用。這裏有一些擴展方法來獲取和設置控制的輔助功能性狀:

public static void SetAccessibilityTraits(this UIResponder responder, UIAccessibilityTraits traits) 
{ 
    responder.SetValueForKey(NSNumber.FromUInt64((ulong)traits), new NSString("accessibilityTraits")); 
} 

public static UIAccessibilityTraits GetAccessibilityTraits(this UIResponder responder) 
{ 
    var value = (NSNumber)responder.ValueForKey(new NSString("accessibilityTraits")); 
    return (UIAccessibilityTraits)value.UInt64Value; 
} 

[Flags] 
public enum UIAccessibilityTraits 
{ 
    None = 0, 
    Button = 1, 
    Link = 2, 
    SearchField = 1024, 
    Image = 4, 
    Selected = 8, 
    PlaysSound = 16, 
    KeyboardKey = 32, 
    StaticText = 64, 
    SummaryElement = 128, 
    NotEnabled = 256, 
    UpdatesFrequently = 512, 
    StartsMediaSession = 2048, 
    Adjustable = 4096, 
    AllowsDirectInteraction = 8192, 
    CausesPageTurn = 16384, 
    Header = 65536  
} 

尼克·懷斯已經發布了一些其他的輔助功能相關的擴展方法here。他們讓您設置輔助功能標籤和控件提示。