 			imageSize = image.size
 
 			if !imageSize.isEmpty && !availableFrame.isEmpty {
-				drawFrame.top = availableFrame.top
-				drawFrame.left = availableFrame.left
-				drawFrame.size = imageSize
-
-				switch contentMode {
-				case .ScaleToFill:
-					drawFrame = availableFrame
-
-				case .ScaleAspectFill, .ScaleAspectFit:
+				switch scaling {
+				case .FitIgnoringAspectRatio:
+					drawFrame.size = availableFrame.size
+
+				case .FitInside, .FitOutside:
 					let horizontalScale = availableFrame.width / imageSize.width
 					let verticalScale = availableFrame.height / imageSize.height
-					let scale = (contentMode == .ScaleAspectFill ? max : min)(horizontalScale, verticalScale)
-
-					drawFrame.width = imageSize.width * scale
-					drawFrame.height = imageSize.height * scale
-
-					fallthrough
-
-				case .Center, .Redraw:
-					drawFrame.left += (availableFrame.width - drawFrame.width) / 2
-					drawFrame.top += (availableFrame.height - drawFrame.height) / 2
-
+					let scale = (scaling == .FitInside ? min : max)(horizontalScale, verticalScale)
+
+					drawFrame.size = imageSize.scaleBy(scale)
+
+				case .FitHorizontally:
+					drawFrame.width = availableFrame.width
+					drawFrame.height = imageSize.height * (drawFrame.width / imageSize.width)
+
+				case .FitHorizontallyIgnoringAspectRatio:
+					drawFrame.width = availableFrame.width
+					drawFrame.height = imageSize.height
+
+				case .FitVertically:
+					drawFrame.height = availableFrame.height
+					drawFrame.width = imageSize.width * (drawFrame.height / imageSize.height)
+
+				case .FitVerticallyIgnoringAspectRatio:
+					drawFrame.height = availableFrame.height
+					drawFrame.width = imageSize.width
+
+				case .None:
+					drawFrame.size = imageSize
+				}
+
+				switch gravity.horizontal {
+				case .Left:
+					drawFrame.left = availableFrame.left
+
+				case .Center:
+					drawFrame.horizontalCenter = availableFrame.horizontalCenter
+
+				case .Right:
+					drawFrame.right = availableFrame.right
+				}
+
+				switch gravity.vertical {
 				case .Top:
-					drawFrame.left += (availableFrame.width - drawFrame.width) / 2
+					drawFrame.top = availableFrame.top
+
+				case .Center:
+					drawFrame.verticalCenter = availableFrame.verticalCenter
 
 				case .Bottom:
-					drawFrame.left += (availableFrame.width - drawFrame.width) / 2
 					drawFrame.bottom = availableFrame.bottom
-
-				case .Left:
-					drawFrame.top += (availableFrame.height - drawFrame.height) / 2
-
-				case .Right:
-					drawFrame.top += (availableFrame.height - drawFrame.height) / 2
-					drawFrame.right = availableFrame.right
-
-				case .TopLeft:
-					break
-
-				case .TopRight:
-					drawFrame.right = availableFrame.right
-
-				case .BottomLeft:
-					drawFrame.bottom = availableFrame.bottom
-
-				case .BottomRight:
-					drawFrame.bottom = availableFrame.bottom
-					drawFrame.right = availableFrame.right
 				}
 
 				drawFrame = roundScaled(drawFrame)

	}


	public override var contentMode: UIViewContentMode {
		didSet {
			if contentMode == oldValue {
				return
			}

			if image != nil {
				setNeedsDisplay()
			}
		}



	public var preferredSize: CGSize?


	@IBInspectable
	public var scaling: Scaling = .FitInside {
		didSet {
			guard scaling != oldValue else {
				return
			}

			if image != nil {
				setNeedsDisplay()
			}
		}
	}


	public override func sizeThatFitsSize(maximumSize: CGSize) -> CGSize {
