Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button padding #14

Closed
robjkc opened this issue Sep 25, 2014 · 9 comments
Closed

Button padding #14

robjkc opened this issue Sep 25, 2014 · 9 comments

Comments

@robjkc
Copy link

robjkc commented Sep 25, 2014

One more small issue, I created my swipe buttons like below, but noticed that there was very little space around the text when displayed on screen.
[MGSwipeButton buttonWithTitle:@"Trash" backgroundColor:[UIColor redColor]];
[MGSwipeButton buttonWithTitle:@"More" backgroundColor:[UIColor lightGrayColor]];

To get around this I added spaces to one of the titles like so which caused both the Trash and More button widths to expand:
[MGSwipeButton buttonWithTitle:@" Trash " backgroundColor:[UIColor redColor]];

Is there a way you could implement a default padding similar to how Apple and components like MSCMoreOptionTableView display so I can avoid doing this myself?

Looking forward to adding this to my app so I can add right swipe as well. Thanks!

@MortimerGoro
Copy link
Owner

There is a better way to add padding than adding spaces to the button titles. After creating a MGSwipeButton you can change it's frame and for example add 10 points to its frame size. You can also toy with UIEdeContentInsets because MGSwipeButton is a UIButton subclass. In the last commit I have added an optional width parameter to MGSwipeButton static constructor to make this easier.

@robjkc
Copy link
Author

robjkc commented Sep 25, 2014

Thanks for the info! Any way to automatically have MGSwipeTableCell handle this? I'm a little worried about scaling issues with different devices. Would rather have MGSwipeTableCell default with a little more padding.

@MortimerGoro MortimerGoro reopened this Sep 25, 2014
MortimerGoro pushed a commit that referenced this issue Sep 25, 2014
@MortimerGoro
Copy link
Owner

On second thought I have changed the width parameter to a padding. I agree that padding is better to handle scaling among many devices. The padding parameter is optional, the default value is 10 points. If you need more customizable paddings you can toy with contentEdgeInsets, titleEdgeInsets and imageEdgeInsets properties and call [button sizeToFit].

Let me know if it works for you now ;)

@robjkc
Copy link
Author

robjkc commented Sep 25, 2014

Thanks! I'll check it out tonight. While you're looking at it, wanted to ask if you happen to size the buttons to the same width if the text differs? It seems like you were, which is a nice feature.

@MortimerGoro
Copy link
Owner

Yes, buttons always have the same width (the size of the larger one) if the text differs.

@robjkc
Copy link
Author

robjkc commented Sep 27, 2014

The buttons look good. One thing I did notice was the after swiping on my extended UITableViewCell all the hidden views on the cell suddenly became visible. I didn't see this in the release from last week. I'll try to create a new issue with a picture.

On Saturday, September 27, 2014 1:24 PM, Imanol Fernandez notifications@github.com wrote:

Closed #14.

Reply to this email directly or view it on GitHub.

@MortimerGoro
Copy link
Owner

Hi robjkc,

I have fixed the hidden views issue, try with the latest version.

@robjkc
Copy link
Author

robjkc commented Sep 30, 2014

Tried it out today and it looks great. Only one last small issue. The default UITableView animation effect when a row is deleted is that the row collapses. For some reason the MGSwipeTableCell doesn't have the same animation effect. Is there a way you can duplicate this?

On Sunday, September 28, 2014 7:21 AM, Imanol Fernandez notifications@github.com wrote:

Hi robjkc,
I have fixed the hidden views issue, try with the latest version.

Reply to this email directly or view it on GitHub.

@jignesh133
Copy link

screen shot 2017-11-03 at 12 10 13 pm

Hi. @MortimerGoro

i have to make the cell like attached the image add some space before the Swipe Button. how can i achive like this.

Thanks in advance,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants