Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Commit

Permalink
Added ability to center placeholder based on NSTextAlignment of the I…
Browse files Browse the repository at this point in the history
…nternalTextView. This is a partial implementation for iOS 7 only.
  • Loading branch information
hanishabsigh committed Nov 6, 2013
1 parent badb68f commit 837a8e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion class/HPTextViewInternal.m
Expand Up @@ -100,7 +100,9 @@ - (void)drawRect:(CGRect)rect
if (self.displayPlaceHolder && self.placeholder && self.placeholderColor)
{
#ifdef __IPHONE_7_0
[self.placeholder drawInRect:CGRectMake(5, 8 + self.contentInset.top, self.frame.size.width-self.contentInset.left, self.frame.size.height- self.contentInset.top) withAttributes:@{NSFontAttributeName:self.font, NSForegroundColorAttributeName:self.placeholderColor}];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = self.textAlignment;
[self.placeholder drawInRect:CGRectMake(5, 8 + self.contentInset.top, self.frame.size.width-self.contentInset.left, self.frame.size.height- self.contentInset.top) withAttributes:@{NSFontAttributeName:self.font, NSForegroundColorAttributeName:self.placeholderColor, NSParagraphStyleAttributeName:paragraphStyle}];
#else
[self.placeholderColor set];
[self.placeholder drawInRect:CGRectMake(8.0f, 8.0f, self.frame.size.width - 16.0f, self.frame.size.height - 16.0f) withFont:self.font];
Expand Down

0 comments on commit 837a8e1

Please sign in to comment.