-
Notifications
You must be signed in to change notification settings - Fork 190
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
Is it possible to increase the view height and allow a multiline subtitle? #111
Comments
You might try creating a custom view for your subtitle and setting this view for the callout's let customSubtitleView = UILabel(frame: .zero)
customSubtitleView.numberOfLines = 2
customSubtitleView.text = "Line 1\nLine 2"
let myCalloutView = SMCalloutView.platform()
myCalloutView.subtitleView = customSubtitleView |
Thanks for your reply. I am pretty new to IOS dev.. Would you be able to show me how to do it in objective C? |
This hasn't been tested, but here's what the equivalent in Objective-C should be: UILabel *customSubtitleView = [[UILabel alloc] initWithFrame:CGRectZero];
customSubtitleView.numberOfLines = 2;
customSubtitleView.text = @"Line 1\nLine 2";
SMCalloutView *myCalloutView = [SMCalloutView platformCalloutView];
myCalloutView.subtitleView = customSubtitleView; |
Thank you. |
Can you post the portion of code where you're creating the callout and setting the subtitle view? |
Here ya go: |
Maybe try setting a larger size instead of UILabel *customSubtitleView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 30)]; (The sizes I used here are sort of arbitrary. I think the callout view is supposed to resize the subtitle to fit the text.) |
Okay, I will try that out. |
I have yet to try the above suggestion however I was able to get behaviour similar to the desired behaviour by messing around with the subtitle and frame heights as well as specifying a number of lines for the subtitlelabel |
I tried the above suggestion and It works! sort of.. It seems the calloutview is not adjusting according to the size of the subtitle view |
What happens if you call [customSubtitleView sizeToFit]; |
So, before adding that I would see "Line 1..." as the subtitle With the above, I see "Line 1" and can see the top of the L for the second line. The height of the calloutview itself does not change however. |
Another thing you could try is wrapping your subtitle view in another view. According to the documentation in SMCalloutView.h:
UIView *subtitleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
[subtitleView addSubview:customSubtitleView];
myCalloutView.subtitleView = subtitleView; |
I will try this.
|
That will work, but I've found it's usually a good idea to keep third-party libraries unmodified so that they can be easily replaced with a newer version in the future. (I've learned this lesson the hard way.) |
Good advice! I wrapped the view as you suggested but it fails to resize accordingly. |
Hey there,
I am wanting to increase the height of the view and display a multi line subtitle.
Is this is supported?
The text was updated successfully, but these errors were encountered: