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

Enable top/bottom positioning of the radio icon. #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MihaiBalint
Copy link

First implementation attempt on getting top/bottom icon positioning to work. This version only works for left-to-right layouts. I created the PR anyway because I wanted to confirm that the implementation is in the correct general direction.

* @brief Icon position: Left, Right, Top or Bottom, default to Left.
* @warning If position is Right, please also set contentHorizontalAlignment to UIControlContentHorizontalAlignmentRight.
* @warning If position is Top or Bottom, please also set contentVerticalAlignment to UIControlContentVerticalAlignmentTop.
* @warning If position is Bottom, please also set contentVerticalAlignment to UIControlContentVerticalAlignmentBottom.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about these warnings... Any idea on how to do it better?

break;
case IconPositionTop:
self.imageEdgeInsets = UIEdgeInsetsMake(0, (self.frame.size.width - self.icon.size.width)*0.5, 0, 0);
self.titleEdgeInsets = UIEdgeInsetsMake(self.icon.size.height, (self.frame.size.width-self.titleLabel.frame.size.width)*0.5 - self.icon.size.width, 0, 0);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, this only works for left-to-right layouts


- (void)setIconOnRight:(BOOL)iconOnRight {
_iconPosition = iconOnRight ? IconPositionRight : IconPositionLeft;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should preserve backwards compatibility.

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

Successfully merging this pull request may close these issues.

None yet

1 participant