Skip to content

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.

1 participant