 extension MarsImageViewController: UIPopoverPresentationControllerDelegate {
     
 }
+
+extension String {
+    func height(withConstrainedWidth width: CGFloat, font: UIFont) -> CGFloat {
+        let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
+        let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
+        
+        return ceil(boundingBox.height)
+    }
+    
+    func width(withConstraintedHeight height: CGFloat, font: UIFont) -> CGFloat {
+        let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
+        let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
+        
+        return ceil(boundingBox.width)
+    }
+}

                self.catalog!.changeToAnaglyph(leftAndRight: leftAndRight, imageIndex: Int(self.currentIndex))
                self.reloadData()
                self.imageSelectionButton.title = "Anaglyph"
            })!
            menuItems.append(menuItem)
        }

            imageName = catalog!.imageName(imageset:imageset, imageIndexInSet:selectedImageIndexInImageset)
        }
        imageSelectionButton.title = imageName
        setImageSelectionButtonWidth()
        getToolbar()?.setNeedsLayout()
    }
    
