[英]How to instantiate custom button from UIButton?
我需要將按鈕設置為CustomButton。
public class MyCustomButton : UIButton
{
string customProperty;
}
我已經有一個UIButton。 現在,我需要將其設為MyCustomButton。
但是顯式類型轉換會導致崩潰。
如何從已經存在的UIButton實例化MyCustomButton?
您需要做的不僅僅是投射導致崩潰的按鈕,該按鈕實際上必須是MyCustomButton
的實例。 無論在何處創建它,都需要將其作為MyCustomButton
而不是UIButton
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.