|
@@ -86,13 +86,17 @@ extension NCSelectableNavigationView {
|
|
|
collectionView.reloadData()
|
|
|
}
|
|
|
|
|
|
- func createViewImageAndText(image: UIImage, title: String) -> UIView {
|
|
|
+ func createViewImageAndText(image: UIImage, title: String? = nil) -> UIView {
|
|
|
|
|
|
let imageView = UIImageView()
|
|
|
let titleView = UIView()
|
|
|
let label = UILabel()
|
|
|
|
|
|
- label.text = title + " "
|
|
|
+ if let title = title {
|
|
|
+ label.text = title + " "
|
|
|
+ } else {
|
|
|
+ label.text = " "
|
|
|
+ }
|
|
|
label.sizeToFit()
|
|
|
label.center = titleView.center
|
|
|
label.textAlignment = NSTextAlignment.center
|
|
@@ -105,12 +109,15 @@ extension NCSelectableNavigationView {
|
|
|
let imageWidth = label.frame.size.height * imageAspect
|
|
|
let imageHeight = label.frame.size.height
|
|
|
|
|
|
- imageView.frame = CGRect(x: imageX, y: imageY, width: imageWidth, height: imageHeight)
|
|
|
+ if title != nil {
|
|
|
+ imageView.frame = CGRect(x: imageX, y: imageY, width: imageWidth, height: imageHeight)
|
|
|
+ titleView.addSubview(label)
|
|
|
+ } else {
|
|
|
+ imageView.frame = CGRect(x: imageX / 2, y: imageY, width: imageWidth, height: imageHeight)
|
|
|
+ }
|
|
|
imageView.contentMode = UIView.ContentMode.scaleAspectFit
|
|
|
|
|
|
- titleView.addSubview(label)
|
|
|
titleView.addSubview(imageView)
|
|
|
-
|
|
|
titleView.sizeToFit()
|
|
|
|
|
|
return titleView
|