1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // FKCirclePublicTextCell.m
- // FirstLink
- //
- // Created by ascii on 16/6/8.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCirclePublicTextCell.h"
- #import "FKCirclePublicTextItem.h"
- @implementation FKCirclePublicTextCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- [self addAllSubviews];
- }
- return self;
- }
- #pragma mark - API
- - (void)configWith:(id)item {
- if ([item isKindOfClass:[FKCirclePublicTextItem class]]) {
- FKCirclePublicTextItem *textItem = (FKCirclePublicTextItem *)item;
-
- self.textView.text = textItem.text;
- self.textView.placeholder = textItem.palceholder;
- self.textView.placeholderColor = UIColorFromRGB(0x999999);
- }
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.textView];
- [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(12);
- make.top.equalTo(self.contentView).offset(0);
- make.right.equalTo(self.contentView).offset(-12);
- make.bottom.equalTo(self.contentView).offset(0);
- }];
- }
- #pragma mark - Method
- + (CGFloat)heightWith:(id)item {
- CGSize size;
- if ([item isKindOfClass:[FKCirclePublicTextItem class]]) {
- FKCirclePublicTextItem *textItem = (FKCirclePublicTextItem*)item;
- UITextView *textView = [[UITextView alloc] init];
- textView.font = [UIFont systemFontOfSize:14];
- textView.text = textItem.text;
-
- CGFloat width = (UISCREENWIDTH - 12 - 12);
- size = [textView sizeThatFits:CGSizeMake(width, MAXFLOAT)];
- }
- return (MAX(54, ceilf(size.height)) + 1);
- }
- #pragma mark - Property
- - (UIPlaceHolderTextView *)textView {
- if (!_textView) {
- _textView = [[UIPlaceHolderTextView alloc] init];
- _textView.font = [UIFont systemFontOfSize:14];
- _textView.textColor = UIColorFromRGB(0x666666);
- _textView.scrollEnabled = NO;
- _textView.returnKeyType = UIReturnKeyDone;
- }
- return _textView;
- }
- @end
|