As far as I can understand you want to display a pop-up to show some text which will be dynamic and can be shown wherever you want just by passing the text.
What you need to do is create a custom view containing a label with top, bottom, leading and trailing constraints whose size would increase based on text. Create a class method with arguments descriptionText:NSString
and onViewController:UIViewController
. Inside it set the frame of your customView according to the text.
You can use the below code if you want to make size dynamic :-
-(CGSize)getLabelSizeFortext:(NSString *)text forWidth:(float)width WithFont:(UIFont *)font
{
CGSize constraint = CGSizeMake(width, MAXFLOAT);
CGRect titleRect = [text boundingRectWithSize:constraint options:(NSStringDrawingUsesLineFragmentOrigin| NSStringDrawingTruncatesLastVisibleLine) attributes:@{NSFontAttributeName:font} context:nil];
return titleRect.size;
}
Inside your class method add your customView to your currentViewController as
onViewController.view.addSubView(self)
You can animate it if you want and let it disappear after few seconds so that the user is able to read the text. As far as appearance is concerned set backgroundColor to [UIColor blackColor] and alpha to 8.0.