示例#1
0
        public static CGSize DrawString(this NSString item, CGRect rect, UIFont font, UILineBreakMode mode, UITextAlignment alignment)
        {
            // Get paragraph style
            var labelStyle = new NSMutableParagraphStyle(NSParagraphStyle.DefaultParagraphStyle.MutableCopy() as AppKit.NSMutableParagraphStyle);

            // Adjust alignment
            labelStyle.Alignment = alignment;

            // Adjust line break mode
            labelStyle.LineBreakMode = mode;

            // Define attributes
            var attributes = new NSStringAttributes()
            {
                Font            = font.NSFont,
                ForegroundColor = UIStringDrawing.FillColor,
                ParagraphStyle  = labelStyle
            };

            // Preform drawing
            item.DrawInRect(rect, attributes);

            // Return new bounding size
            return(new CGSize(rect.Width, rect.Height));
        }