Last active
August 3, 2017 08:26
-
-
Save clmntcrl/8e4cab3ed7d1e7da47e7 to your computer and use it in GitHub Desktop.
ShapedButton is a UIButton subclass optimized for non-rectangular button shapes written in Swift. ShapedButton respond to touches only in areas where the flattened button image (background image + image + title label) for state .Normal is non-transparent. This implementation is based on OBShapedButton by Ole Begemann (https://github.com/ole/OBSh…
Hi, for some reason I get memory error when using this. I have a function that adds 10 buttons with pngs as backgrounds but everytime I click one of the buttons it adds to the memorybuffer an after about 10 clicks the app crash due to memory issues. Do you know what could cause this?
Will this be updated for Swift 3? I'm having trouble getting it functioning.
Is anyone working on swift 3 for this?
Hi All, Here is it in Swift 3 .
https://gist.github.com/rizvvan/d6def79882bda9f916463b2feaeaf64a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated it for Swift 2.0 with following code. Seems to work fine so far but you might wanna check!
Thanks!
var pixelData: [CUnsignedChar] = [0, 0, 0, 0]
let bytesPerPixel = 4
let bytesPerRow = bytesPerPixel * 1
let bitsPerComponent = 8
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue | CGBitmapInfo.ByteOrder32Little.rawValue)
let context = CGBitmapContextCreate(&pixelData, 1, 1, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue)
CGContextSetBlendMode(context, CGBlendMode.Copy)