中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

php動態(tài)網(wǎng)站開發(fā)簡介網(wǎng)站制作平臺

php動態(tài)網(wǎng)站開發(fā)簡介,網(wǎng)站制作平臺,坑梓網(wǎng)站建設(shè)信息,九江網(wǎng)站建設(shè)公司iOS開發(fā)-實現(xiàn)熱門話題標(biāo)簽tag顯示控件 話題標(biāo)簽tag顯示非常常見,如選擇你的興趣,選擇關(guān)注的群,超話,話題等等。 一、效果圖 二、實現(xiàn)代碼 由于顯示的是在列表中,這里整體控件是放在UITableViewCell中的。 2.1 標(biāo)簽…

iOS開發(fā)-實現(xiàn)熱門話題標(biāo)簽tag顯示控件

話題標(biāo)簽tag顯示非常常見,如選擇你的興趣,選擇關(guān)注的群,超話,話題等等。

一、效果圖

在這里插入圖片描述

二、實現(xiàn)代碼

由于顯示的是在列表中,這里整體控件是放在UITableViewCell中的。

2.1 標(biāo)簽tag按鈕實現(xiàn)

自定義標(biāo)簽tag按鈕INRmdTopicButton
INRmdTopicButton.h

@interface INRmdTopicButton : UIControl@property (nonatomic, strong) NSString *topicName;
@property (nonatomic, assign) CGFloat showTopicWidth;+ (CGFloat)topicWidth:(NSString *)name;@end

INRmdTopicButton.m

@interface INRmdTopicButton ()@property (nonatomic, strong) UIImageView *backImageView;       //圖片控件
@property (nonatomic, strong) UIImageView *tbkImageView;       //圖片控件
@property (nonatomic, strong) UILabel *titleLabel;@end@implementation INRmdTopicButton- (instancetype)initWithFrame:(CGRect)frame
{self = [super initWithFrame:frame];if (self) {[self addSubview:self.backImageView];[self.backImageView addSubview:self.tbkImageView];[self.backImageView addSubview:self.titleLabel];}return self;
}- (void)layoutSubviews {[super layoutSubviews];self.backImageView.frame = self.bounds;self.tbkImageView.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self.backImageView.frame), CGRectGetHeight(self.backImageView.frame) - kSmallPadding);self.titleLabel.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self.backImageView.frame), kTopicNameHeight);
}- (void)setTopicName:(NSString *)topicName {_topicName = (topicName?topicName:@"");self.titleLabel.text = _topicName;[self setNeedsLayout];
}+ (CGFloat)topicWidth:(NSString *)name {CGSize topicSize = [name sizeWithFont:[UIFont systemFontOfSize:12] forMaxSize:CGSizeMake(MAXFLOAT, kTopicHeight)];return topicSize.width + 2*kSmallPadding;
}#pragma mark - SETTER/GETTER
- (UIImageView *)backImageView {if (!_backImageView) {_backImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_backImageView.userInteractionEnabled = YES;_backImageView.backgroundColor = [UIColor clearColor];}return _backImageView;
}- (UIImageView *)tbkImageView {if (!_tbkImageView) {_tbkImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_tbkImageView.userInteractionEnabled = YES;_tbkImageView.backgroundColor = [UIColor clearColor];UIImage *image = [UIImage imageNamed:@"bk_topic_r"];image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width * 0.5) topCapHeight:floorf(image.size.height * 0.5)];_tbkImageView.image = image;}return _tbkImageView;
}- (UILabel *)titleLabel {if (!_titleLabel) {_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];_titleLabel.font = [UIFont systemFontOfSize:12];_titleLabel.textAlignment = NSTextAlignmentCenter;_titleLabel.textColor = [UIColor colorWithHexString:@"555555"];_titleLabel.backgroundColor = [UIColor clearColor];}return _titleLabel;
}@end

2.2 顯示排列標(biāo)簽tag

顯示標(biāo)題tag時候,需要排列按鈕

INRmdTopicButton *lastButton = nil;for (UIView *subView in self.topicBKImageView.subviews) {if ([subView isKindOfClass:[INRmdTopicButton class]]) {INRmdTopicButton *button = (INRmdTopicButton *)subView;button.hidden = NO;if (lastButton) {if (CGRectGetMaxX(lastButton.frame) + button.showTopicWidth + kSmallPadding > maxWidth) {button.frame = CGRectMake(0.0, CGRectGetMaxY(lastButton.frame), button.showTopicWidth, kTopicHeight);} else {button.frame = CGRectMake(CGRectGetMaxX(lastButton.frame) + kSmallPadding, CGRectGetMinY(lastButton.frame), button.showTopicWidth, kTopicHeight);}} else {button.frame = CGRectMake(originX, originY, button.showTopicWidth, kTopicHeight);}if (CGRectGetMaxY(button.frame) > maxHeight) {button.hidden = YES;} else {button.hidden = NO;}lastButton = button;}}

這里還加了拖動手勢UIPanGestureRecognizer,當(dāng)往左拖動的時候會顯示松開換一換的功能。調(diào)用接口實現(xiàn)。

#pragma mark - panGestureHandle
- (void)panGestureHandle:(UIPanGestureRecognizer *)pan{if (pan.state == UIGestureRecognizerStateBegan) {NSLog(@"UIGestureRecognizerStateBegan");self.startPoint = [pan translationInView:self];} if (pan.state == UIGestureRecognizerStateChanged) {NSLog(@"UIGestureRecognizerStateChanged");CGPoint point = [pan translationInView:self];CGFloat xDistance = point.x - self.startPoint.x;// 左右滑動NSLog(@"左右滑動");if (xDistance > 0) {NSLog(@"向右滑動");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding;self.topicBKImageView.frame = backFrame;} else {NSLog(@"向左滑動");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding + xDistance*0.5;self.topicBKImageView.frame = backFrame;}} else {// if (pan.state == UIGestureRecognizerStateEnded || pan.state == UIGestureRecognizerStateCancelled || pan.state == UIGestureRecognizerStateFailed)NSLog(@"UIGestureRecognizerStateEnded");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding;[UIView animateWithDuration:0.55 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:7.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{self.topicBKImageView.frame = backFrame;} completion:^(BOOL finished) {}];}
}-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {return YES;
}

2.3 完整代碼如下

INRecommentTopicCell.h

#import <UIKit/UIKit.h>@interface INRmdTopicButton : UIControl@property (nonatomic, strong) NSString *topicName;
@property (nonatomic, assign) CGFloat showTopicWidth;+ (CGFloat)topicWidth:(NSString *)name;@end/**推薦的話題*/
@interface INRecommentTopicCell : UITableViewCell+ (CGFloat)cellHeight;@end

INRecommentTopicCell.m

#import "INRecommentTopicCell.h"
#import "UIColor+Addition.h"
#import "NSString+Size.h"static CGFloat kCellHeight = 260.0;static CGFloat kCellHorBGPadding = 10.0f;
static CGFloat kCellVerBGPadding = 5.0f;static CGFloat kTitleHeight = 44.0f;
static CGFloat kMidPadding = 10.0f;static CGFloat kSmallPadding = 5.0f;
static CGFloat kTopicHeight = 40.0f;
static CGFloat kTopicNameHeight = 30.0f;static CGFloat kExchangeBtnSize = 40.0f;
static CGFloat kTisWidth = 20.0f;@interface INRmdTopicButton ()@property (nonatomic, strong) UIImageView *backImageView;       //圖片控件
@property (nonatomic, strong) UIImageView *tbkImageView;       //圖片控件
@property (nonatomic, strong) UILabel *titleLabel;@end@implementation INRmdTopicButton- (instancetype)initWithFrame:(CGRect)frame
{self = [super initWithFrame:frame];if (self) {[self addSubview:self.backImageView];[self.backImageView addSubview:self.tbkImageView];[self.backImageView addSubview:self.titleLabel];}return self;
}- (void)layoutSubviews {[super layoutSubviews];self.backImageView.frame = self.bounds;self.tbkImageView.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self.backImageView.frame), CGRectGetHeight(self.backImageView.frame) - kSmallPadding);self.titleLabel.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self.backImageView.frame), kTopicNameHeight);
}- (void)setTopicName:(NSString *)topicName {_topicName = (topicName?topicName:@"");self.titleLabel.text = _topicName;[self setNeedsLayout];
}+ (CGFloat)topicWidth:(NSString *)name {CGSize topicSize = [name sizeWithFont:[UIFont systemFontOfSize:12] forMaxSize:CGSizeMake(MAXFLOAT, kTopicHeight)];return topicSize.width + 2*kSmallPadding;
}#pragma mark - SETTER/GETTER
- (UIImageView *)backImageView {if (!_backImageView) {_backImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_backImageView.userInteractionEnabled = YES;_backImageView.backgroundColor = [UIColor clearColor];}return _backImageView;
}- (UIImageView *)tbkImageView {if (!_tbkImageView) {_tbkImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_tbkImageView.userInteractionEnabled = YES;_tbkImageView.backgroundColor = [UIColor clearColor];UIImage *image = [UIImage imageNamed:@"bk_topic_r"];image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width * 0.5) topCapHeight:floorf(image.size.height * 0.5)];_tbkImageView.image = image;}return _tbkImageView;
}- (UILabel *)titleLabel {if (!_titleLabel) {_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];_titleLabel.font = [UIFont systemFontOfSize:12];_titleLabel.textAlignment = NSTextAlignmentCenter;_titleLabel.textColor = [UIColor colorWithHexString:@"555555"];_titleLabel.backgroundColor = [UIColor clearColor];}return _titleLabel;
}@end/**推薦的話題*/
@interface INRecommentTopicCell ()@property (nonatomic, strong) UIImageView *backImageView;       //圖片控件
@property (nonatomic, strong) UIImageView *contentBGImageView;       //圖片控件
@property (nonatomic, strong) UIImageView *topicBKImageView;       //圖片控件
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *exchangeButton;     // 更多@property (nonatomic, strong) UILabel *tipsLabel;@property (nonatomic) CGPoint startPoint;     // 開始點@end@implementation INRecommentTopicCell- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];if (self) {// Initialization codeself.backgroundColor = [UIColor clearColor];self.contentView.backgroundColor = [UIColor clearColor];[self.contentView addSubview:self.backImageView];[self.contentView addSubview:self.contentBGImageView];[self.contentBGImageView addSubview:self.titleLabel];[self.contentBGImageView addSubview:self.exchangeButton];[self.contentBGImageView addSubview:self.tipsLabel];[self.contentBGImageView addSubview:self.topicBKImageView];[self setupRmdTopicViews];UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureHandle:)];panGesture.minimumNumberOfTouches = 1;panGesture.maximumNumberOfTouches = 1;panGesture.delegate = self;[self.contentBGImageView addGestureRecognizer:panGesture];}return self;
}- (void)layoutSubviews {[super layoutSubviews];self.backImageView.frame = CGRectMake(kCellHorBGPadding, kCellVerBGPadding, CGRectGetWidth(self.bounds) - 2*kCellHorBGPadding, CGRectGetHeight(self.bounds) - 2*kCellVerBGPadding);self.contentBGImageView.frame = CGRectMake(kCellHorBGPadding, kCellVerBGPadding, CGRectGetWidth(self.bounds) - 2*kCellHorBGPadding, CGRectGetHeight(self.bounds) - 2*kCellVerBGPadding);self.titleLabel.frame = CGRectMake(kMidPadding, 0.0, CGRectGetWidth(self.backImageView.frame) - 3*kMidPadding - kExchangeBtnSize, kTitleHeight);self.exchangeButton.frame = CGRectMake(CGRectGetWidth(self.backImageView.frame) - kMidPadding - kExchangeBtnSize, (kTitleHeight - kExchangeBtnSize)/2, kExchangeBtnSize, kExchangeBtnSize);CGFloat height = CGRectGetHeight(self.backImageView.frame) - CGRectGetMaxY(self.titleLabel.frame);self.tipsLabel.frame = CGRectMake(CGRectGetWidth(self.backImageView.frame) - kMidPadding - kTisWidth, 0.0, kTisWidth, height);self.topicBKImageView.frame = CGRectMake(kMidPadding, CGRectGetMaxY(self.titleLabel.frame), CGRectGetWidth(self.backImageView.frame) - 2*kMidPadding, height);CGFloat maxWidth = CGRectGetWidth(self.topicBKImageView.frame);CGFloat maxHeight = CGRectGetHeight(self.topicBKImageView.frame);CGFloat originX = 0.0;CGFloat originY = 0.0;INRmdTopicButton *lastButton = nil;for (UIView *subView in self.topicBKImageView.subviews) {if ([subView isKindOfClass:[INRmdTopicButton class]]) {INRmdTopicButton *button = (INRmdTopicButton *)subView;button.hidden = NO;if (lastButton) {if (CGRectGetMaxX(lastButton.frame) + button.showTopicWidth + kSmallPadding > maxWidth) {button.frame = CGRectMake(0.0, CGRectGetMaxY(lastButton.frame), button.showTopicWidth, kTopicHeight);} else {button.frame = CGRectMake(CGRectGetMaxX(lastButton.frame) + kSmallPadding, CGRectGetMinY(lastButton.frame), button.showTopicWidth, kTopicHeight);}} else {button.frame = CGRectMake(originX, originY, button.showTopicWidth, kTopicHeight);}if (CGRectGetMaxY(button.frame) > maxHeight) {button.hidden = YES;} else {button.hidden = NO;}lastButton = button;}}
}- (void)setupRmdTopicViews {for (UIView *subView in self.topicBKImageView.subviews) {if ([subView isKindOfClass:[INRmdTopicButton class]]) {[subView removeFromSuperview];}}for (NSInteger index = 0; index < 15; index ++) {INRmdTopicButton *button = [[INRmdTopicButton alloc] initWithFrame:CGRectZero];button.tag = index;[self.topicBKImageView addSubview:button];if (index % 5 == 0) {button.topicName = @"#讀書交流";} else if (index % 5 == 1) {button.topicName = @"#愛手工生活";} else if (index % 5 == 2) {button.topicName = @"#精致的佛系生活";} else if (index % 5 == 3) {button.topicName = @"#數(shù)碼發(fā)燒友";} else if (index % 5 == 4) {button.topicName = @"#曬曬你的心情";} else {button.topicName = @"#說說身邊事";}button.showTopicWidth = [INRmdTopicButton topicWidth:button.topicName];}[self setNeedsLayout];
}- (void)setSelected:(BOOL)selected animated:(BOOL)animated {[super setSelected:selected animated:animated];// Configure the view for the selected state
}+ (CGFloat)cellHeight {return kCellHeight;
}#pragma mark - Actions
- (void)exchangeButtonAction {}#pragma mark - SETTER/GETTER
- (UIImageView *)backImageView {if (!_backImageView) {_backImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_backImageView.userInteractionEnabled = YES;_backImageView.backgroundColor = [UIColor whiteColor];_backImageView.layer.cornerRadius = 2.0;_backImageView.layer.shadowColor = [UIColor colorWithHexString:@"9bb9ef"].CGColor;_backImageView.layer.shadowOffset = CGSizeMake(0, 3);_backImageView.layer.shadowOpacity = 0.3;_backImageView.layer.shadowRadius = 3.0;}return _backImageView;
}- (UIImageView *)contentBGImageView {if (!_contentBGImageView) {_contentBGImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_contentBGImageView.userInteractionEnabled = YES;_contentBGImageView.backgroundColor = [UIColor whiteColor];_contentBGImageView.layer.cornerRadius = 2.0;_contentBGImageView.layer.masksToBounds = YES;_contentBGImageView.clipsToBounds = YES;}return _contentBGImageView;
}- (UIImageView *)topicBKImageView {if (!_topicBKImageView) {_topicBKImageView = [[UIImageView alloc] initWithFrame:CGRectZero];_topicBKImageView.userInteractionEnabled = YES;_topicBKImageView.backgroundColor = [UIColor whiteColor];_topicBKImageView.clipsToBounds = YES;}return _topicBKImageView;
}- (UILabel *)titleLabel {if (!_titleLabel) {_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];_titleLabel.font = [UIFont systemFontOfSize:18];_titleLabel.textColor = [UIColor colorWithHexString:@"131619"];_titleLabel.backgroundColor = [UIColor clearColor];_titleLabel.text = @"熱門話題";}return _titleLabel;
}- (UILabel *)tipsLabel {if (!_tipsLabel) {_tipsLabel = [[UILabel alloc] initWithFrame:CGRectZero];_tipsLabel.font = [UIFont systemFontOfSize:12];_tipsLabel.textColor = [UIColor colorWithHexString:@"9a9b9c"];_tipsLabel.backgroundColor = [UIColor clearColor];_tipsLabel.numberOfLines = 0;_tipsLabel.textAlignment = NSTextAlignmentCenter;_tipsLabel.text = @"松\n開\n換\n一\n換";}return _tipsLabel;
}- (UIButton *)exchangeButton {if (!_exchangeButton) {_exchangeButton = [UIButton buttonWithType:UIButtonTypeCustom];[_exchangeButton setImage:[UIImage imageNamed:@"ic_topic_exchange"] forState:UIControlStateNormal];[_exchangeButton addTarget:self action:@selector(exchangeButtonAction) forControlEvents:UIControlEventTouchUpInside];}return _exchangeButton;
}#pragma mark - panGestureHandle
- (void)panGestureHandle:(UIPanGestureRecognizer *)pan{if (pan.state == UIGestureRecognizerStateBegan) {NSLog(@"UIGestureRecognizerStateBegan");self.startPoint = [pan translationInView:self];} if (pan.state == UIGestureRecognizerStateChanged) {NSLog(@"UIGestureRecognizerStateChanged");CGPoint point = [pan translationInView:self];CGFloat xDistance = point.x - self.startPoint.x;// 左右滑動NSLog(@"左右滑動");if (xDistance > 0) {NSLog(@"向右滑動");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding;self.topicBKImageView.frame = backFrame;} else {NSLog(@"向左滑動");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding + xDistance*0.5;self.topicBKImageView.frame = backFrame;}} else {// if (pan.state == UIGestureRecognizerStateEnded || pan.state == UIGestureRecognizerStateCancelled || pan.state == UIGestureRecognizerStateFailed)NSLog(@"UIGestureRecognizerStateEnded");CGRect backFrame = self.topicBKImageView.frame;backFrame.origin.x = kMidPadding;[UIView animateWithDuration:0.55 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:7.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{self.topicBKImageView.frame = backFrame;} completion:^(BOOL finished) {}];}
}-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {return YES;
}@end

三、小結(jié)

iOS開發(fā)-實現(xiàn)熱門話題標(biāo)簽tag顯示控件
話題標(biāo)簽tag顯示非常常見,如選擇你的興趣,選擇關(guān)注的群,超話,話題等等。

學(xué)習(xí)記錄,每天不停進(jìn)步。

http://www.risenshineclean.com/news/48479.html

相關(guān)文章:

  • 自己怎么做系統(tǒng)網(wǎng)站能打開的a站
  • 共享辦公室 設(shè)計網(wǎng)站性能優(yōu)化
  • 鐵漢生態(tài)建設(shè)有限公司網(wǎng)站最新黑帽seo培訓(xùn)
  • 如何做屬于自己的領(lǐng)券網(wǎng)站廈門人才網(wǎng)最新招聘信息
  • 越南做企業(yè)網(wǎng)站百度云電腦版網(wǎng)站入口
  • 廣寧縣住房和城鄉(xiāng)建設(shè)局網(wǎng)站seo優(yōu)化標(biāo)題 關(guān)鍵詞
  • 一個網(wǎng)站多個域名重定向怎么做南京搜索引擎推廣優(yōu)化
  • 響應(yīng)式網(wǎng)站建設(shè)團(tuán)隊全網(wǎng)天下網(wǎng)站開發(fā)制作培訓(xùn)學(xué)校
  • 怎么做婚戀網(wǎng)站百度收錄是什么意思
  • 跨境電商網(wǎng)站建設(shè)方案網(wǎng)站優(yōu)化排名易下拉穩(wěn)定
  • 附近網(wǎng)站建設(shè)公司哪家好注冊網(wǎng)站免費注冊
  • 要找企業(yè)做網(wǎng)站應(yīng)該注意什么網(wǎng)站優(yōu)化外包推薦
  • 河源建設(shè)用地競拍網(wǎng)站2024年新冠疫情最新消息今天
  • 信息網(wǎng)站建設(shè)預(yù)算windows優(yōu)化大師和360哪個好
  • 怎么在自己電腦上建網(wǎng)站今日競彩足球最新比賽結(jié)果查詢
  • 營銷系統(tǒng)有哪些南昌seo排名外包
  • 網(wǎng)站主頁模板友情鏈接檢測平臺
  • 建一家網(wǎng)站多少錢濰坊網(wǎng)站建設(shè)方案咨詢
  • 游戲類網(wǎng)頁設(shè)計優(yōu)化推廣
  • 網(wǎng)站建設(shè)設(shè)計時代創(chuàng)信好找廣告商的平臺
  • 企業(yè)網(wǎng)站平臺如何做網(wǎng)絡(luò)推廣視頻剪輯培訓(xùn)
  • 網(wǎng)站備案主體查詢河南seo優(yōu)化
  • 網(wǎng)絡(luò)規(guī)劃設(shè)計師2022云優(yōu)化
  • 怎做賣東西的網(wǎng)站如何快速網(wǎng)絡(luò)推廣
  • ecshop 獲取網(wǎng)站域名日照網(wǎng)絡(luò)推廣公司
  • 網(wǎng)站pc開發(fā)上海如何寫好軟文
  • 網(wǎng)站流量分析系統(tǒng)百度企業(yè)認(rèn)證怎么認(rèn)證
  • 高性能網(wǎng)站建設(shè)進(jìn)階指南 pdf知乎seo排名帝搜軟件
  • 英語課件做的好的網(wǎng)站百度云資源
  • 企業(yè)網(wǎng)站的建立視頻廣州各區(qū)風(fēng)險區(qū)域最新動態(tài)