cemolcay / CEMKit-Swift

UIKit & Foundation toolbelt for quick prototyping and rapid development
MIT License
40 stars 7 forks source link

Practical use of leftWithOffset #4

Open Esqarrouth opened 9 years ago

Esqarrouth commented 9 years ago
func leftWithOffset(offset: CGFloat) -> CGFloat {
    return self.left - offset
}

func rightWithOffset(offset: CGFloat) -> CGFloat {
    return self.right + offset
}

func topWithOffset(offset: CGFloat) -> CGFloat {
    return self.top - offset
}

func bottomWithOffset(offset: CGFloat) -> CGFloat {
    return self.bottom + offset
}

Where do you use these methods? Thanks for the extensions

cemolcay commented 9 years ago

hi, thanks ! you can use them for laying out your views manually for example, if you want align two views horizontally with 10px padding

let padding: CGFloat = 10
let viewW: CGFloat = (self.view.w - padding*3) / 2 
let viewH: CGFloat = 50

let firstView = UIView(x: padding, y: padding, w: viewW, h: viewH)
self.view.addSubview(firstView)

let secondView = UIView(x: firstView.rightWithOffset(padding), y: padding, w: viewW, h: viewH)
self.view.addSubview(secondView)
Esqarrouth commented 9 years ago

I didn't understand it with your code but tested and it is perfectly thought out. http://prntscr.com/7sz6v7

Sorry to barrage you with questions but,

  1. Btw couldn't get this one to work drawArc(), what am I missing?
  2. Do you use spring() except for pop()?
  3. toImage() this only turns it to black and white images, is it how this is intended to be used?
  4. addTapGestureWithOverlay whats this intended for?
  5. How do you use these?

    public init(stringLiteral value: StringLiteralType) { self = CGPointFromString(value) }

    public init(extendedGraphemeClusterLiteral value: StringLiteralType) { self = CGPointFromString(value) }

    public init(unicodeScalarLiteral value: StringLiteralType) { self = CGPointFromString(value) }

  6. For what do you use these?

normalizeValue convertNormalizedValue clamp aspectHeightForTargetAspectWidth aspectWidthForTargetAspectHeight

  1. How do you use BlockButton?
Esqarrouth commented 8 years ago

I am still wondering about these :)