Permalink
Browse files

Modified textAlignment implementation to remove the ivar.

  • Loading branch information...
1 parent 9dbb55e commit 37599b15cb8d17436cba0fd7b791e6b4edf22fa3 @BigZaphod committed Dec 16, 2011
Showing with 11 additions and 10 deletions.
  1. +0 −1 UIKit/Classes/UITextLayer.h
  2. +11 −9 UIKit/Classes/UITextLayer.m
@@ -75,7 +75,6 @@
UIColor *textColor;
UIFont *font;
BOOL changingResponderStatus;
- UITextAlignment textAlignment;
struct {
unsigned int didChange : 1;
@@ -55,7 +55,6 @@ - (id)initWithContainer:(UIView <UITextLayerContainerViewProtocol, UITextLayerTe
self.masksToBounds = NO;
containerView = aView;
- textAlignment = UITextAlignmentLeft;
textDelegateHas.didChange = [containerView respondsToSelector:@selector(_textDidChange)];
textDelegateHas.didChangeSelection = [containerView respondsToSelector:@selector(_textDidChangeSelection)];
@@ -71,9 +70,9 @@ - (id)initWithContainer:(UIView <UITextLayerContainerViewProtocol, UITextLayerTe
textView = [(UICustomNSTextView *)[UICustomNSTextView alloc] initWithFrame:[clipView frame] secureTextEntry:secureTextEntry isField:isField];
[textView setDelegate:self];
- [textView setAlignment:NSLeftTextAlignment];
[clipView setDocumentView:textView];
-
+
+ self.textAlignment = UITextAlignmentLeft;
[self setNeedsLayout];
}
return self;
@@ -267,10 +266,8 @@ - (void)setSelectedRange:(NSRange)range
[textView setSelectedRange:range];
}
-- (void)setTextAlignment:(UITextAlignment)value
+- (void)setTextAlignment:(UITextAlignment)textAlignment
{
- textAlignment = value;
-
switch (textAlignment) {
case UITextAlignmentLeft:
[textView setAlignment:NSLeftTextAlignment];
@@ -281,14 +278,19 @@ - (void)setTextAlignment:(UITextAlignment)value
case UITextAlignmentRight:
[textView setAlignment:NSRightTextAlignment];
break;
- default:
- break;
}
}
- (UITextAlignment)textAlignment
{
- return textAlignment;
+ switch ([textView alignment]) {
+ case NSCenterTextAlignment:
+ return UITextAlignmentCenter;
+ case NSRightTextAlignment:
+ return UITextAlignmentRight;
+ default:
+ return UITextAlignmentLeft;
+ }
}
// this is used to fake out AppKit when the UIView that owns this layer/editor stuff is actually *behind* another UIView. Since the NSViews are

0 comments on commit 37599b1

Please sign in to comment.