CEMKit-Swift icon indicating copy to clipboard operation
CEMKit-Swift copied to clipboard

Practical use of leftWithOffset

Open Esqarrouth opened this issue 8 years ago • 3 comments

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

Esqarrouth avatar Jul 15 '15 01:07 Esqarrouth

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)

cemolcay avatar Jul 15 '15 08:07 cemolcay

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 avatar Jul 15 '15 13:07 Esqarrouth

I am still wondering about these :)

Esqarrouth avatar Oct 19 '15 08:10 Esqarrouth