okmr-d / DOFavoriteButton

Cute Animated Button written in Swift.
MIT License
3.61k stars 297 forks source link

Is there a way to change the image size #16

Open kiwo12345 opened 9 years ago

kiwo12345 commented 9 years ago

First off, thanks for sharing this! Is there a way to change the image size? Increasing the button size does not work.

vicorente commented 9 years ago

I solved it by doing this in DOFavoriteButton.swift:

private func createLayers(image image: UIImage!) {
 ...
 let imageFrame = self.frame 
 let imgCenterPoint = CGPointMake(CGRectGetMidX(imageFrame), CGRectGetMidY(imageFrame))
 let lineFrame = self.frame
 ...
}     

First you have to define the frame for the button.

itsaark commented 8 years ago

@vicorente I implemented the above code, but I don't see any button on the view. Is this something to do with defining the frame? If so, can you please guide me?

vicorente commented 8 years ago

Sure!! Show me your code here...

itsaark commented 8 years ago

I defined a frame for likeButton in viewDidLoad

likeButton.frame = CGRect(x: 220, y: 330, width: 22, height: 24)

And I have implemented your code in DOFavoriteButton.swift. But nothing shows up in the simulator.

vicorente commented 8 years ago

Create yout likeButton like this:

let likeButton = DOFavoriteButton(frame: CGRectMake(0,0,44,44), image: UIImage(named: "likeImage")!)

After this check that you add the button as a subview of any view in your view controller.

itsaark commented 8 years ago

Thanks! I'll try this.

Shahid452 commented 8 years ago

In create layer function, just change the imageFrame like

private func createLayers(image image: UIImage!) { .... let imageFrame = CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height) ...... }

Then it will work. Dont know why the developer kept those parameters but above parameters are correct.