uiimageview - Overriding the class's property swift -
i want override contentmode of uiimageview wrote code doesn't seem work expected.
class aspectfituiimageview: uiimageview { override var contentmode: uiviewcontentmode { { return .scaleaspectfit } set { // contentmode = contentmode } } }
can 1 tell me wrong?
you should set contentmode in awakefromnib() so:
class aspectfituiimageview: uiimageview { override func awakefromnib() { super.awakefromnib() contentmode = .scaleaspectfit } }
or if not planning on using nib or storyboard, can use following:
override init(frame: cgrect) { super.init(frame: frame) contentmode = .scaleaspectfit }
Comments
Post a Comment