2012-11-21 38 views
1

我試圖將端口AUISelectiveBordersView鏈接到MonoTouch。 它基本上是CALayer的一個子類,並通過類別在UIView中集成。MonoTouch - 如何覆蓋靜態UIView.layerClass

AUISelectiveBordersLayer的「翻譯」很簡單,但整合點有點棘手。在obj-c它是這樣做的:

@implementation UIView (AUISelectiveBorder) 

+(Class) layerClass { 
    return [AUISelectiveBordersLayer class]; 
} 

有什麼辦法可以將它轉換成MonoTouch?它看起來像覆蓋靜態方法,但我在MT中看不到任何像layerClasslayerType

回答

4

幸好我發現,它通過子類UIView的工作原理:

public class UIViewWithSelectiveBorders : UIView { 

    [Export("layerClass")] 
    public static Class LayerClass() { 
     return new Class (typeof(SelectiveBorderLayer)); 
    } 
} 

在這足以讓我的任務的時刻,但更普遍的問題仍然是實際的:有沒有辦法改變這種狀況沒有子UIView(例如,如果我想覆蓋所有的UILabel s)

+1

有一種方法。但是這涉及到更多的工作,而不僅僅是繼承UILabel。你上面這樣做的方式很少。 –

+0

你能給一個這樣的鏈接嗎?我非常感興趣的情況下,它將需要在即將到來的任務 – Shaddix

+0

你能幫助嗎? http://stackoverflow.com/questions/15174025/monotouch-how-to-override-static-uicollectionviewlayout-layoutattributesclass – nbransby