bhlvoong / LBTATools

Set of tools to drastically improve development speed of UI in iOS applications
MIT License
727 stars 94 forks source link

Added UIImageView convenience initialiser #14

Closed zakbarlow1995 closed 4 years ago

zakbarlow1995 commented 5 years ago

Added UIImageView convenience initialiser to generalise AspectFitImageView & AspectFillImageView UIImageView subclasses (AspectFitImageView.swift removed).

This matches the UIKit extension convention for custom initialisers present in LBTATools (UIButton.swift, UILabel.swift, UIStackView.swift, UITextField+Tools.swift, and UITextView.swift).

zakbarlow1995 commented 5 years ago

Apart from improved generality this change also prevents false assumptions arising from the (subclass) name itself, for example:

let imageView = UIImageView(contentMode: .scaleAspectFit)
let aspectFitImageView = AspectFitImageView()

func modifyImages() {
    imageView.contentMode = .scaleAspectFill
    aspectFitImageView.contentMode = .scaleAspectFill
}

Once modifyImages() is called, the AspectFitImageView instance has a misnomer in both class and (likely) variable name, whereas someone isn't likely to assume the contentMode of a standard UIImageView.

bhlvoong commented 4 years ago

I'm quite hesitant on accepting UIImageView changes for this library. None of the solutions I see, including mine, are that great in my opinion.