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

boundingRectWithSize issue since converting to Swift 2.0 #69

Closed
amjohnno opened this issue Jun 14, 2015 · 2 comments
Closed

boundingRectWithSize issue since converting to Swift 2.0 #69

amjohnno opened this issue Jun 14, 2015 · 2 comments

Comments

@amjohnno
Copy link

I've converted my app to Swift 2.0, which hasn't gone very successfully so far! I'm getting one issue with SCLAlertView with boundingRectWithSize in the following code:

// Subtitle
if !subTitle.isEmpty {
    viewText.text = subtitle
    // Adjust text view size, if necessary
    let str = subTitle as NSString
    let attr = [NSFontAttributeName:viewText.font]
    let sz = CGSize(width: kWindowWidth - 24, height:90)
    let r = str.boundingRectWithSize(sz, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes:attr, context:nil)
    let ht = ceil(r.size.height)
    if ht < kTextHeight {
        kWindowHeight -= (kTextHeight - ht)
        kTextHeight = ht
    }
}

The error reads:

Cannot invoke 'boundingRectWithSize' with an argument list of type '(CGSize, options: NSStringDrawingOptions, attributes: [String : UIFont?], context: nil)'

Is this just me, or have others found this?

@vishnupillai9
Copy link

I came across this too. You need to unwrap viewText.font. The argument attributes for boundingRectWithSize method should be of type [String : UIFont]. Since viewText.font is not unwrapped, attr is currently of type [String : UIFont?].

@amjohnno
Copy link
Author

That's perfect. Thanks, @vishnupillai9.

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

2 participants