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

Text alignment issue #16

Open
AussieSam opened this issue Sep 21, 2018 · 0 comments
Open

Text alignment issue #16

AussieSam opened this issue Sep 21, 2018 · 0 comments

Comments

@AussieSam
Copy link

AussieSam commented Sep 21, 2018

I believe that there is an issue which makes the text alignment dependent on the "View As" selection made it xCode. This means that it will not be possible to make the drop down appear correctly on both an iPhone and iPad at the same time.

To clarify, this is only an issue when you specify leading and trailing widths to say superview. If instead, you were to center the UIDropdown on the x axis and explicitly specify the width then you would have no issue, but you would have a small dropdown on an iPad

The below change appears to have fixed the issue, I have used screenSize.width rather than self.frame.width

    fileprivate func setup() {
    let screenSize: CGRect = UIScreen.main.bounds
    let screenWidth = screenSize.width
    let screenHeight = screenSize.height
    title = UILabel(frame: CGRect(x: 0,
                                  y: 0,
                                  width: (screenWidth-self.frame.height),
                                  height: self.frame.height))

    title.textAlignment = .center
     print("\(self.frame.width)")
    print("\(screenWidth)")
    self.addSubview(title)

There may be a way to specify the object width when the dropdown is set up. I tried but it didnt affect the actual size of self.frame.width inside the UIDropDown class

dropDown1.frame = CGRect(x: 0, y:0, width: self.view.frame.width, height: self.view.frame.height)
    dropDown1.center = CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)

If there is a way to use your original code but specify the width so that self.frame.width is not dependent on the Storyboard "view as" device type then could you please tell me how to do that?

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

1 participant