Just My Life & My Work

Archive for 2015 年 09 月 20 日

[iOS] 自訂性質 (Customize Property)

我們自己定義的類別當然可以自訂性質 (Customize Property),但是若是SDK內建的類別,繼承其類別來自訂性質可就不建議,不過我們有特殊作法!

聽聽神人怎麼說:

The Cocoa frameworks take the approach that the Object Composition pattern is more appropriate than traditional class hierarchy.

In general, this means that there is likely to be a property on UIButton where you can set another object to handle various aspects of the button. This is the preferred way to “customize" how your button works.

One of the main reasons for this pattern is that many library components create buttons and don’t know that you want them to create instances of your subclass.

(繼續閱讀…)

標籤雲

%d 位部落客按了讚: