Skip to content

Commit

Permalink
Use UIView instead of UIButton for container
Browse files Browse the repository at this point in the history
This fixes accessibility issues and improves testability.
  • Loading branch information
fphilipe committed Jan 27, 2017
1 parent a67b171 commit 28a3b5c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Classes/PHFComposeBarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ @interface PHFComposeBarView ()
@property (strong, nonatomic, readonly) UIView *topLineView;
@property (strong, nonatomic, readonly) UILabel *charCountLabel;
@property (strong, nonatomic) PHFDelegateChain *delegateChain;
@property (strong, nonatomic, readonly) UIButton *textContainer;
@property (strong, nonatomic, readonly) UIView *textContainer;
@property (assign, nonatomic) CGFloat previousTextHeight;
@end

Expand Down Expand Up @@ -332,14 +332,13 @@ - (UILabel *)charCountLabel {
@synthesize textContainer = _textContainer;
// Returns the text container which contains the actual text view, the
// placeholder and the image view that contains the text field image.
- (UIButton *)textContainer {
- (UIView *)textContainer {
if (!_textContainer) {
CGRect textContainerFrame = CGRectMake(kHorizontalSpacing,
kTextContainerTopMargin,
[self bounds].size.width - kHorizontalSpacing * 3 - kButtonRightMargin,
[self bounds].size.height - kTextContainerTopMargin - kTextContainerBottomMargin);
_textContainer = [UIButton buttonWithType:UIButtonTypeCustom];
[_textContainer setFrame:textContainerFrame];
_textContainer = [[UIView alloc] initWithFrame:textContainerFrame];
[_textContainer setClipsToBounds:YES];
[_textContainer setBackgroundColor:[UIColor colorWithWhite:0.98f alpha:1.0f]];
[_textContainer setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
Expand Down Expand Up @@ -368,8 +367,6 @@ - (UIButton *)textContainer {
kPlaceholderHeight);
[[self placeholderLabel] setFrame:placeholderFrame];
[_textContainer addSubview:[self placeholderLabel]];

[_textContainer addTarget:[self textView] action:@selector(becomeFirstResponder) forControlEvents:UIControlEventTouchUpInside];
}

return _textContainer;
Expand Down

0 comments on commit 28a3b5c

Please sign in to comment.