This commit is contained in:
lianxiang
2018-09-27 00:20:01 +08:00
parent d0230f55ed
commit cb0accdb66
60 changed files with 1063 additions and 290 deletions
+44 -30
View File
@@ -25,7 +25,8 @@
self.frame = CGRectMake(0, 0, 0, height);
_msgModel = model;
//self.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.5];
self.backgroundColor = [UIColor redColor];
//self.backgroundColor = [UIColor redColor];
[self initUI];
}
return self;
@@ -40,43 +41,48 @@
-(void)initUI{
UIImageView *avatar = [[UIImageView alloc] init];
avatar.layer.masksToBounds = YES;
avatar.layer.cornerRadius = 15;
[self addSubview:avatar];
[avatar sd_setImageWithURL:[NSURL URLWithString:_msgModel.sendUserHeadImg] placeholderImage:[UIImage imageNamed:@"nav_circle_avatar"]];
self.userAvtar = avatar;
[self.userAvtar mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(30);
make.height.mas_equalTo(30);
make.left.mas_equalTo(self.mas_left).mas_offset(3);
make.top.mas_equalTo(self.mas_top).mas_offset(3);
}];
// UIImageView *avatar = [[UIImageView alloc] init];
// avatar.layer.masksToBounds = YES;
// avatar.layer.cornerRadius = 15;
// [self addSubview:avatar];
// [avatar sd_setImageWithURL:[NSURL URLWithString:_msgModel.sendUserHeadImg] placeholderImage:[UIImage imageNamed:@"nav_circle_avatar"]];
// self.userAvtar = avatar;
// [self.userAvtar mas_makeConstraints:^(MASConstraintMaker *make) {
// make.width.mas_equalTo(30);
// make.height.mas_equalTo(30);
// make.left.mas_equalTo(self.mas_left).mas_offset(3);
// make.top.mas_equalTo(self.mas_top).mas_offset(3);
//
// }];
UILabel *namelabel = [[UILabel alloc] init];
namelabel.font = [UIFont systemFontOfSize:14];
namelabel.textColor = [UIColor blackColor];
namelabel.font = GIGA_TEXTFONTBOLD(15);
namelabel.textColor = [UIColor whiteColor];
//namelabel.frame= CGRectMake(CGRectGetMaxX(avatar.frame) + 5, 4, namelabel.frame.size.width, namelabel.frame.size.height);
namelabel.text = @"用户名";
namelabel.text = @"用户名:";
if (_msgModel.sendUserName && _msgModel.sendUserName.length > 0) {
namelabel.text = [_msgModel.sendUserName replaceUnicode:_msgModel.sendUserName];
namelabel.text = [NSString stringWithFormat:@"%@:",_msgModel.sendUserName];
}
[namelabel sizeToFit];
self.userName = namelabel;
[self addSubview:self.userName];
// [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
//
// make.left.mas_equalTo(self.userAvtar.mas_right).mas_offset(3);
// make.top.mas_equalTo(self.mas_top).mas_offset(10);
//
// }];
[self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).offset(3);
make.centerY.mas_equalTo(self.mas_centerY);
make.left.mas_equalTo(self.userAvtar.mas_right).mas_offset(3);
make.top.mas_equalTo(self.mas_top).mas_offset(10);
}];
UILabel *msglabel = [[UILabel alloc] init];
msglabel.font = [UIFont systemFontOfSize:13];
msglabel.textColor = [UIColor blackColor];
msglabel.font = GIGA_TEXTFONTMEDIUM(13);
msglabel.textColor = [UIColor whiteColor];
//msglabel.frame= CGRectMake(namelabel.frame.origin.x, CGRectGetMaxY(avatar.frame) - msglabel.frame.size.height - namelabel.frame.origin.y, msglabel.frame.size.width, msglabel.frame.size.height);
msglabel.text = @"信息内容";
if (_msgModel.content && _msgModel.content.length > 0) {
msglabel.text = [_msgModel.content replaceUnicode:_msgModel.content];
@@ -84,17 +90,25 @@
self.msg = msglabel;
[msglabel sizeToFit];
[self addSubview:self.msg];
// [self.msg mas_makeConstraints:^(MASConstraintMaker *make) {
//
// make.top.mas_equalTo(self.userAvtar.mas_bottom).mas_offset(3);
// make.left.mas_equalTo(self.mas_left).mas_offset(5);
//
// }];
[self.msg mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.userAvtar.mas_bottom).mas_offset(3);
make.left.mas_equalTo(self.mas_left).mas_offset(5);
make.left.mas_equalTo(namelabel.mas_right).offset(2);
make.centerY.mas_equalTo(self.mas_centerY);
}];
[self layoutIfNeeded];
float width = msglabel.frame.size.width > namelabel.frame.size.width ? msglabel.frame.size.width:namelabel.frame.size.width ;
// float width = msglabel.frame.size.width > namelabel.frame.size.width ? msglabel.frame.size.width:namelabel.frame.size.width ;
float width = msglabel.frame.size.width + namelabel.frame.size.width;
self.frame = CGRectMake(0, 0, namelabel.frame.origin.x + 10 + width, self.frame.size.height);
self.frame = CGRectMake(0, 0, width, self.frame.size.height);
}
@end
@@ -16,7 +16,10 @@
}
-(void)comfirmTitles:(NSIndexPath *)indepath
{
NSArray *titles = @[@"手机相册",@"系统相册",@"自拍"];
NSArray *titles = @[@"手机相册",@"系统相册",@"自拍",@"取消"];
if (indepath.row == 3) {
self.sheetTitle.textColor = GIGARGB(165,165, 165, 1);
}
self.sheetTitle.text = titles[indepath.row];
}
@@ -14,5 +14,6 @@
@property (weak, nonatomic) IBOutlet UILabel *timeLabe;
@property (weak, nonatomic) IBOutlet UILabel *percetLabe;
@property (weak, nonatomic) IBOutlet UILabel *totalLabe;
@property (weak, nonatomic) IBOutlet UIImageView *userAvtoar;
@end
@@ -20,6 +20,9 @@
self.timeBackVIew.layer.shadowOffset = CGSizeMake(2,1);
self.timeBackVIew.layer.shadowColor = GIGARGB(91, 91, 91, 0.6).CGColor;
self.timeBackVIew.layer.shadowOpacity = 0.8;
self.userAvtoar.layer.masksToBounds = YES;
self.userAvtoar.layer.cornerRadius = 4;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
@@ -178,6 +178,7 @@
<outlet property="timeBackVIew" destination="H7C-wU-YeM" id="q2o-NG-UKS"/>
<outlet property="timeLabe" destination="znk-jF-QRT" id="pii-LG-rfu"/>
<outlet property="totalLabe" destination="ZJ1-li-JLb" id="MeX-lM-Wfv"/>
<outlet property="userAvtoar" destination="ocM-SZ-rcr" id="buS-pJ-uPg"/>
<outlet property="userIcon" destination="ocM-SZ-rcr" id="VxR-wi-5fs"/>
</connections>
<point key="canvasLocation" x="34" y="53.5"/>
@@ -7,9 +7,13 @@
//
#import <UIKit/UIKit.h>
typedef void (^actionSheetAction)(NSUInteger index);
@interface MaskTimeShareActionSheet : UIView
@interface MaskTimeShareActionSheet : UIViewController
@property(nonatomic,copy) actionSheetAction action;
-(void)show:(actionSheetAction)action;
+(MaskTimeShareActionSheet *)showAtView:(UIViewController *)vc;
@end
@@ -15,58 +15,55 @@
@implementation MaskTimeShareActionSheet
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; ;
[self creatUI];
}
return self;
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
[self creatUI];
}
-(void)creatUI{
UIView *holdview =[[UIView alloc] init];
holdview.frame =CGRectMake(0,KMainH - 216 - 60 -20 , KMainW, 216 + 60 +20);
holdview.backgroundColor = [UIColor whiteColor];
// CGRect backRect= holdview.frame;
//
holdview.frame =CGRectMake(0,KMainH - 216 , KMainW, 216);
holdview.backgroundColor = [UIColor whiteColor];
//CGRect backRect= holdview.frame;
// UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:backRect byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
// CAShapeLayer *maskLayer =[[CAShapeLayer alloc] init];
// maskLayer.frame = backRect;
// maskLayer.path = maskPath.CGPath;
// holdview.layer.mask = maskLayer;
holdview.layer.masksToBounds = YES;
holdview.layer.cornerRadius = 10;
[self addSubview:holdview];
// holdview.layer.masksToBounds = YES;
// holdview.layer.cornerRadius = 10;
[self.view addSubview:holdview];
self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KMainW, 216 + 60) style:UITableViewStylePlain];
self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KMainW, 216) style:UITableViewStylePlain];
self.tabview.backgroundColor = [UIColor whiteColor];
self.tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tabview.delegate = self;
self.tabview.scrollEnabled = NO;
self.tabview.dataSource = self;
UIButton *cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
[cancleBtn setTitleColor:GIGARGB(165,165, 165, 1) forState:UIControlStateNormal];
[cancleBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
cancleBtn.frame = CGRectMake(0,1, KMainW,60);
self.tabview.tableFooterView = cancleBtn;
[holdview addSubview:self.tabview];
}
+(MaskTimeShareActionSheet *)showAtView:(UIViewController *)vc{
MaskTimeShareActionSheet *Sheet = [[MaskTimeShareActionSheet alloc] init];
if (ISIOS8) {
Sheet.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}else{
Sheet.modalPresentationStyle = UIModalPresentationCurrentContext;
}
[vc presentViewController:Sheet animated:YES completion:nil];
return Sheet;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 3;
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@@ -82,11 +79,16 @@
return 54;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (self.action) {
self.action(indexPath.row);
if (indexPath.row == 3) {
[self cancleDissmiss];
}else{
[self cancleDissmiss];
if (self.action) {
self.action(indexPath.row);
}
}
}
-(void)show:(actionSheetAction)action{
@@ -106,10 +108,8 @@
}
-(void)cancleDissmiss{
[UIView animateWithDuration:1.0 animations:^{
self.tabview.frame = CGRectMake(0, KMainH - 216, KMainW, 0);
}];
[self removeFromSuperview];
[self dismissViewControllerAnimated:NO completion:nil];
}
@@ -9,5 +9,7 @@
#import <UIKit/UIKit.h>
@interface MaskTimeShareViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *doinglabel;
@property (weak, nonatomic) IBOutlet UIImageView *shareLabe;
@end
@@ -41,7 +41,7 @@
<constraint firstAttribute="height" constant="35" id="zzS-Dk-zsi"/>
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="share_one" translatesAutoresizingMaskIntoConstraints="NO" id="dlk-Er-Voj">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="share_oneblack" translatesAutoresizingMaskIntoConstraints="NO" id="dlk-Er-Voj">
<rect key="frame" x="42" y="229" width="162" height="19"/>
<constraints>
<constraint firstAttribute="height" constant="19" id="JLN-Jh-Gue"/>
@@ -63,12 +63,16 @@
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="doinglabel" destination="ajv-9T-Bcf" id="Le0-Q8-0zg"/>
<outlet property="shareLabe" destination="dlk-Er-Voj" id="iWt-Wf-6y7"/>
</connections>
<point key="canvasLocation" x="34" y="53.5"/>
</tableViewCell>
</objects>
<resources>
<image name="share_logo" width="185" height="85"/>
<image name="share_one" width="133" height="17"/>
<image name="share_oneblack" width="133" height="17"/>
<image name="share_two" width="155" height="35"/>
</resources>
</document>
@@ -57,7 +57,7 @@
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="这是您敷面膜的第:10" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o4N-kZ-Uph">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="这是您敷面膜的第:10" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o4N-kZ-Uph">
<rect key="frame" x="193" y="17" width="111" height="14"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="10"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -19,33 +19,44 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="89.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gqo-NQ-qFy">
<rect key="frame" x="24" y="24" width="120" height="40"/>
<color key="backgroundColor" red="0.70980392156862748" green="0.054901960784313725" blue="0.054901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="og4-sa-zcc">
<rect key="frame" x="12" y="5" width="297" height="78"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gqo-NQ-qFy">
<rect key="frame" x="15" y="19" width="120" height="40"/>
<color key="backgroundColor" red="0.70980392156862748" green="0.054901960784313725" blue="0.054901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="fbO-WJ-dOx"/>
<constraint firstAttribute="height" constant="40" id="j7c-6V-Nkv"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="18"/>
<state key="normal" title="更换背景"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="scf-Jn-nCG">
<rect key="frame" x="163" y="19" width="120" height="40"/>
<color key="backgroundColor" red="0.70980392160000005" green="0.054901960780000002" blue="0.054901960780000002" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="IbN-g5-5Dk"/>
<constraint firstAttribute="height" constant="40" id="YlE-4r-yHL"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="18"/>
<state key="normal" title="分享"/>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="TPM-XU-L0w"/>
<constraint firstAttribute="width" constant="120" id="ZPK-wp-9E9"/>
<constraint firstAttribute="height" constant="78" id="DO7-hs-rG7"/>
<constraint firstAttribute="width" constant="297" id="J73-5q-ui5"/>
<constraint firstItem="Gqo-NQ-qFy" firstAttribute="centerY" secondItem="og4-sa-zcc" secondAttribute="centerY" id="KLB-Wx-4AS"/>
<constraint firstItem="Gqo-NQ-qFy" firstAttribute="leading" secondItem="og4-sa-zcc" secondAttribute="leading" constant="15" id="QzO-BI-GP4"/>
<constraint firstItem="scf-Jn-nCG" firstAttribute="centerY" secondItem="og4-sa-zcc" secondAttribute="centerY" id="cgO-tC-6O7"/>
<constraint firstAttribute="trailing" secondItem="scf-Jn-nCG" secondAttribute="trailing" constant="14" id="twO-fW-Eua"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="18"/>
<state key="normal" title="更换背景"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="scf-Jn-nCG">
<rect key="frame" x="176" y="24" width="120" height="40"/>
<color key="backgroundColor" red="0.70980392160000005" green="0.054901960780000002" blue="0.054901960780000002" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Yva-pt-o9N"/>
<constraint firstAttribute="width" constant="120" id="mNM-uk-QUs"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Semibold" family="PingFang SC" pointSize="18"/>
<state key="normal" title="分享"/>
</button>
</view>
</subviews>
<constraints>
<constraint firstItem="scf-Jn-nCG" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Gqo-NQ-qFy" secondAttribute="trailing" constant="32" id="MSN-NY-psb"/>
<constraint firstItem="scf-Jn-nCG" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="fxv-dG-WQl"/>
<constraint firstAttribute="trailing" secondItem="scf-Jn-nCG" secondAttribute="trailing" constant="24" id="iv9-Dq-7bp"/>
<constraint firstItem="Gqo-NQ-qFy" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="sta-hl-p4d"/>
<constraint firstItem="Gqo-NQ-qFy" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="24" id="y1w-d5-yav"/>
<constraint firstItem="og4-sa-zcc" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="dvj-W6-RMX"/>
<constraint firstItem="og4-sa-zcc" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="kRr-5g-gSI"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
@@ -13,5 +13,6 @@
@property (weak, nonatomic) IBOutlet UILabel *timeLabe;
@property (weak, nonatomic) IBOutlet UILabel *percentLabe;
@property (weak, nonatomic) IBOutlet UILabel *totalTime;
@property (weak, nonatomic) IBOutlet UIImageView *useravator;
@end
@@ -19,6 +19,8 @@
self.timeholdBack.layer.shadowColor = GIGARGB(233, 226, 226, 1).CGColor;
self.timeholdBack.layer.shadowOpacity = 1;
//self.timeholdBack.layer.shadowRadius = 6;
self.useravator.layer.masksToBounds = YES;
self.useravator.layer.cornerRadius = 4;
}
@@ -105,13 +105,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="%的用户" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Kf-o0-1q0">
<rect key="frame" x="171.5" y="139" width="48" height="17"/>
<rect key="frame" x="175.5" y="139" width="48" height="17"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="12"/>
<color key="textColor" red="0.21568627450980393" green="0.21568627450980393" blue="0.21568627450980393" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="min" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dic-3G-CvO">
<rect key="frame" x="307" y="139" width="21" height="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dic-3G-CvO">
<rect key="frame" x="311" y="139" width="21" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="7vV-ZK-S0b"/>
<constraint firstAttribute="width" constant="21" id="8AJ-vw-Jnl"/>
@@ -137,16 +137,16 @@
<constraint firstItem="dic-3G-CvO" firstAttribute="top" secondItem="j6s-4L-8FL" secondAttribute="bottom" constant="33" id="Ht3-2Y-5Mb"/>
<constraint firstItem="Tme-2V-NlI" firstAttribute="top" secondItem="R09-WA-3qM" secondAttribute="bottom" constant="26" id="KUx-Nw-4kf"/>
<constraint firstItem="R09-WA-3qM" firstAttribute="top" secondItem="tEV-Hx-dgE" secondAttribute="top" constant="61" id="LNc-ql-jSY"/>
<constraint firstAttribute="trailing" secondItem="dic-3G-CvO" secondAttribute="trailing" constant="13" id="Lb3-Ut-P6Z"/>
<constraint firstAttribute="trailing" secondItem="dic-3G-CvO" secondAttribute="trailing" constant="9" id="Lb3-Ut-P6Z"/>
<constraint firstItem="8Kf-o0-1q0" firstAttribute="top" secondItem="Tme-2V-NlI" secondAttribute="bottom" constant="33" id="Lev-qu-Zmr"/>
<constraint firstItem="xEv-bM-Qny" firstAttribute="top" secondItem="Tme-2V-NlI" secondAttribute="bottom" constant="4" id="P0c-5d-JJq"/>
<constraint firstItem="UA6-7v-cad" firstAttribute="leading" secondItem="tEV-Hx-dgE" secondAttribute="leading" constant="19" id="Tzt-3x-Lfy"/>
<constraint firstAttribute="trailing" secondItem="Yg7-YX-5c6" secondAttribute="trailing" constant="14" id="Usm-zC-hhp"/>
<constraint firstItem="8Kf-o0-1q0" firstAttribute="leading" secondItem="xEv-bM-Qny" secondAttribute="trailing" constant="-1" id="VD9-bi-F2d"/>
<constraint firstItem="8Kf-o0-1q0" firstAttribute="leading" secondItem="xEv-bM-Qny" secondAttribute="trailing" constant="3" id="VD9-bi-F2d"/>
<constraint firstItem="Yd8-h2-8ZW" firstAttribute="top" secondItem="j6s-4L-8FL" secondAttribute="bottom" constant="3" id="XWR-b8-Nl1"/>
<constraint firstItem="SKr-dU-xbP" firstAttribute="top" secondItem="TkO-iO-bzM" secondAttribute="bottom" constant="4" id="lYD-5E-uY3"/>
<constraint firstItem="UA6-7v-cad" firstAttribute="top" secondItem="tEV-Hx-dgE" secondAttribute="top" constant="10" id="mLH-mh-9mJ"/>
<constraint firstItem="dic-3G-CvO" firstAttribute="leading" secondItem="Yd8-h2-8ZW" secondAttribute="trailing" constant="-3" id="rVx-wc-qRN"/>
<constraint firstItem="dic-3G-CvO" firstAttribute="leading" secondItem="Yd8-h2-8ZW" secondAttribute="trailing" constant="1" id="rVx-wc-qRN"/>
<constraint firstItem="5p1-hF-pIU" firstAttribute="leading" secondItem="SKr-dU-xbP" secondAttribute="trailing" constant="8" id="sm5-de-qgC"/>
<constraint firstItem="Yg7-YX-5c6" firstAttribute="top" secondItem="tEV-Hx-dgE" secondAttribute="top" constant="20" id="vNY-Db-SYT"/>
<constraint firstItem="j6s-4L-8FL" firstAttribute="top" secondItem="R09-WA-3qM" secondAttribute="bottom" constant="26" id="xu2-eN-sWL"/>
@@ -166,6 +166,7 @@
<outlet property="timeLabe" destination="SKr-dU-xbP" id="LAX-mi-LrF"/>
<outlet property="timeholdBack" destination="tEV-Hx-dgE" id="oFa-dy-K2h"/>
<outlet property="totalTime" destination="Yd8-h2-8ZW" id="3pB-KH-2ui"/>
<outlet property="useravator" destination="UA6-7v-cad" id="Wyb-DM-w0i"/>
</connections>
<point key="canvasLocation" x="33.5" y="53.5"/>
</tableViewCell>
@@ -0,0 +1,27 @@
//
// MaskTimeTopAnimationView.h
// GIGA
//
// Created by lianxiang on 2018/9/26.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@class MaskTimeTopAnimationView;
@protocol MaskTimeTextViewDelegate <NSObject>
@optional
- (void)gyChangeTextView:(MaskTimeTopAnimationView *)textView didTapedAtIndex:(NSInteger)index;
@end
@interface MaskTimeTopAnimationView : UIView
@property (nonatomic, assign) id<MaskTimeTextViewDelegate> delegate;
- (void)animationWithTexts:(NSArray *)textAry;
- (void)stopAnimation;
@end
@@ -0,0 +1,131 @@
//
// MaskTimeTopAnimationView.m
// GIGA
//
// Created by lianxiang on 2018/9/26.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "MaskTimeTopAnimationView.h"
#define DEALY_WHEN_TITLE_IN_MIDDLE 5.0
#define DEALY_WHEN_TITLE_IN_BOTTOM 0.0
typedef NS_ENUM(NSUInteger, GYTitlePosition) {
GYTitlePositionTop = 1,
GYTitlePositionMiddle = 2,
GYTitlePositionBottom = 3
};
@interface MaskTimeTopAnimationView()
@property (nonatomic, strong) UILabel *textLabel;
@property (nonatomic, strong) NSArray *contentsAry;
@property (nonatomic, assign) CGPoint topPosition;
@property (nonatomic, assign) CGPoint middlePosition;
@property (nonatomic, assign) CGPoint bottomPosition;
/*
*1.控制延迟时间,当文字在中间时,延时时间长一些,如5秒,这样可以让用户浏览清楚内容;
*2.当文字隐藏在底部的时候,不需要延迟,这样衔接才流畅;
*3.通过上面的宏定义去更改需要的值
*/
@property (nonatomic, assign) CGFloat needDealy;
@property (nonatomic, assign) NSInteger currentIndex; /*当前播放到那个标题了*/
@property (nonatomic, assign) BOOL shouldStop; /*是否停止*/
@end
@implementation MaskTimeTopAnimationView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
//self.backgroundColor = [UIColor whiteColor];
self.topPosition = CGPointMake(self.frame.size.width/2 -22, -self.frame.size.height/2);
self.middlePosition = CGPointMake(self.frame.size.width/2 - 22, self.frame.size.height/2);
self.bottomPosition = CGPointMake(self.frame.size.width/2 -22 , self.frame.size.height/2*3);
self.shouldStop = NO;
_textLabel = [[UILabel alloc] init];
//_textLabel.backgroundColor = [UIColor blackColor];
_textLabel.layer.bounds = CGRectMake(0,0, CGRectGetWidth(frame), CGRectGetHeight(frame));
_textLabel.layer.position = self.middlePosition;
_textLabel.textAlignment = NSTextAlignmentCenter;
_textLabel.textColor = [UIColor whiteColor];
_textLabel.font = GIGA_TEXTFONTMEDIUM(13);
[self.layer addSublayer:_textLabel.layer];
self.clipsToBounds = NO; /*保证文字不跑出视图YES*/
self.needDealy = DEALY_WHEN_TITLE_IN_MIDDLE; /*控制第一次显示时间*/
self.currentIndex = 0;
}
return self;
}
- (void)animationWithTexts:(NSArray *)textAry {
self.contentsAry = textAry;
self.textLabel.text = [textAry objectAtIndex:0];
//[self.textLabel sizeToFit];
[self startAnimation];
}
- (void)startAnimation {
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.3 delay:self.needDealy options:UIViewAnimationOptionCurveEaseInOut animations:^{
if ([weakSelf currentTitlePosition] == GYTitlePositionMiddle) {
weakSelf.textLabel.layer.position = weakSelf.topPosition;
} else if ([weakSelf currentTitlePosition] == GYTitlePositionBottom) {
weakSelf.textLabel.layer.position = weakSelf.middlePosition;
}
} completion:^(BOOL finished) {
if ([weakSelf currentTitlePosition] == GYTitlePositionTop) {
weakSelf.textLabel.layer.position = weakSelf.bottomPosition;
weakSelf.needDealy = DEALY_WHEN_TITLE_IN_BOTTOM;
weakSelf.currentIndex ++;
weakSelf.textLabel.text = [weakSelf.contentsAry objectAtIndex:[weakSelf realCurrentIndex]];
} else {
weakSelf.needDealy = DEALY_WHEN_TITLE_IN_MIDDLE;
}
if (!weakSelf.shouldStop) {
[weakSelf startAnimation];
} else { //停止动画后,要设置label位置和label显示内容
weakSelf.textLabel.layer.position = weakSelf.middlePosition;
weakSelf.textLabel.text = [weakSelf.contentsAry objectAtIndex:[weakSelf realCurrentIndex]];
}
}];
}
- (void)stopAnimation {
self.shouldStop = YES;
}
- (NSInteger)realCurrentIndex {
return self.currentIndex % [self.contentsAry count];
}
- (GYTitlePosition)currentTitlePosition {
if (self.textLabel.layer.position.y == self.topPosition.y) {
return GYTitlePositionTop;
} else if (self.textLabel.layer.position.y == self.middlePosition.y) {
return GYTitlePositionMiddle;
}
return GYTitlePositionBottom;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
if ([self.delegate respondsToSelector:@selector(gyChangeTextView:didTapedAtIndex:)]) {
[self.delegate gyChangeTextView:self didTapedAtIndex:[self realCurrentIndex]];
}
}
//- (CGSize)intrinsicContentSize
//
//{
//
// return UILayoutFittingExpandedSize;
//
//}
@end