I've create a subview and implementing the drawRect: method for custom drawing. How do I achieve a behavior similar to that of a UILabel which automatically adds the Ellipsis (...) if the text is too long to fit in its frame.
Here is the code
- (void)drawRect:(CGRect)rect
{
NSDictionary *attributes = @{NSFontAttributeName : [UIFont systemFontOfSize:16.0f], NSForegroundColorAttributeName : [UIColor blackColor]};
[self.sampleText drawInRect:CGRectMake(10.0f, 10.0f, self.frame.size.width - 20.0f, self.frame.size.height - 20.0f) withAttributes:attributes];
}
If the sampleText is long then it just gets clipped to fit within the specified rect. How do I add the '...' appropriately?