From c5ed8f087339345ee7c695ee8038e6d7f07fff3a Mon Sep 17 00:00:00 2001 From: kai60 Date: Thu, 5 May 2022 16:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish.xcodeproj/project.pbxproj | 8 + .../normalImage.imageset/Contents.json | 2 - .../normalImage.imageset/normalImage.png | Bin 221 -> 982 bytes .../normalImage.imageset/normalImage@2x.png | Bin 322 -> 0 bytes .../normalImage.imageset/normalImage@3x.png | Bin 409 -> 0 bytes .../selectedImage.imageset/Contents.json | 2 - .../selectedImage.imageset/selectedImage.png | Bin 211 -> 886 bytes .../selectedImage.imageset/selectedImage@2x.png | Bin 314 -> 0 bytes .../selectedImage.imageset/selectedImage@3x.png | Bin 403 -> 0 bytes .../Category/UIButton+ImageTitleStyle.h | 38 ++++ .../Category/UIButton+ImageTitleStyle.m | 185 ++++++++++++++++++ .../XuTo/TimerTypeTableViewCell.h | 15 +- .../XuTo/TimerTypeTableViewCell.m | 77 +++++++- .../XuTo/TimerTypeTableViewCell.xib | 31 --- .../XuTo/Xuanduo2SettingController.h | 3 + .../XuTo/Xuanduo2TimerModel.h | 9 + .../XuTo/XuanduoTimerSettingViewController.h | 3 +- .../XuTo/XuanduoTimerSettingViewController.m | 15 +- .../sendmaseegemodel/ReadTimerModel.h | 1 + 19 files changed, 339 insertions(+), 50 deletions(-) delete mode 100644 Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage@2x.png delete mode 100644 Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage@3x.png delete mode 100644 Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@2x.png delete mode 100644 Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@3x.png create mode 100644 Ifish/Utinitys/Category/UIButton+ImageTitleStyle.h create mode 100644 Ifish/Utinitys/Category/UIButton+ImageTitleStyle.m diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index c5193b9..ccc5ddb 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -2284,6 +2284,8 @@ C02D9E562794011300BBBF8D /* AlicloudHttpDNS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02D9E4F2794011100BBBF8D /* AlicloudHttpDNS.framework */; }; C02ED596249E3B7300CAC37D /* InfoByImageViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */; }; C02ED597249E3B7300CAC37D /* InfoByImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */; }; + C057166C282376CC004F113A /* UIButton+ImageTitleStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */; }; + C057166D282376CC004F113A /* UIButton+ImageTitleStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */; }; C072196A253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */; }; C072196D253B1F4F0065CF17 /* DatePickerCustomView.h in Headers */ = {isa = PBXBuildFile; fileRef = C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */; }; C072196E253B1F4F0065CF17 /* DatePickerCustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */; }; @@ -5776,6 +5778,8 @@ C02D9E4F2794011100BBBF8D /* AlicloudHttpDNS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AlicloudHttpDNS.framework; sourceTree = ""; }; C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoByImageViewController.h; sourceTree = ""; }; C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoByImageViewController.m; sourceTree = ""; }; + C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIButton+ImageTitleStyle.h"; sourceTree = ""; }; + C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIButton+ImageTitleStyle.m"; sourceTree = ""; }; C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IfishP2PPlayBackListViewController.xib; sourceTree = ""; }; C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatePickerCustomView.h; sourceTree = ""; }; C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatePickerCustomView.m; sourceTree = ""; }; @@ -12398,6 +12402,8 @@ C0C4CCFD272CDF4A00574BE8 /* UIViewController+Navgation.m */, C017B1E0245ED2D3003151DF /* UIImage+WaterMark.h */, C017B1E1245ED2D4003151DF /* UIImage+WaterMark.m */, + C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */, + C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */, ); path = Category; sourceTree = ""; @@ -13057,6 +13063,7 @@ 3D1C50BA221A9EE00096AE43 /* NetManager.h in Headers */, C0E7D6D023A1D16D00256A10 /* Constant.h in Headers */, CB484DF622B8C8C80075F050 /* eval.h in Headers */, + C057166C282376CC004F113A /* UIButton+ImageTitleStyle.h in Headers */, 3D1C513A221A9EE10096AE43 /* FishControlFirstCell.h in Headers */, 3D1C50EC221A9EE00096AE43 /* MessageDAO.h in Headers */, CB484DF322B8C8C80075F050 /* timecode.h in Headers */, @@ -15380,6 +15387,7 @@ 8864841F1EE166A40046C3BD /* RuSunChangeNameTextViewCell.m in Sources */, 88779EAB1E28999600209ABA /* JuNengCCSetViewController.m in Sources */, 883E762A1D4897570030E075 /* merchantModel.m in Sources */, + C057166D282376CC004F113A /* UIButton+ImageTitleStyle.m in Sources */, 883E78451D48A5E50030E075 /* KeLiAiCenterViewController.m in Sources */, 883E76231D4897570030E075 /* MyChatRoomModel.m in Sources */, 883E78551D48A5E50030E075 /* TwoControlSetTimeViewController.m in Sources */, diff --git a/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/Contents.json b/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/Contents.json index 0b884a8..37b5b77 100644 --- a/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/Contents.json +++ b/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/Contents.json @@ -6,12 +6,10 @@ "scale" : "1x" }, { - "filename" : "normalImage@2x.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "normalImage@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage.png b/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage.png index 9949653bf13efac3101d86eb57fcb5083b090140..c0c129b1c8d2673c2477bb4dfbfc3e30e979668b 100644 GIT binary patch literal 982 zcmeAS@N?(olHy`uVBq!ia0vp^{2!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBDAAG{;hE;^%b*2hb1<+n z3NbJPS&Tr)z$nE4G7ZRL@M4sPvx68lplX;H7}_%#SfFa6fHVkr05M1pgl1mAh%j*h z6I?a_0%imor0omOHjpPd3p^r=85p>QL70(Y)*J~21}1~dkcg59UmvUF{9L`nl>DSr zy^7odkS+$B3M(KpH?<^Dp&~aYuh^=>Rtc=a3djZt>nkaMm6T-LDnNc-DA*LGq*(>IxIwi8dA3R!B_#z``ugSN<$C4Ddih1^`i7R4mih)p`bI{& zKoz>hm3bwJ6}oxF$`C_f=D4I5Cl_TFlw{`TDS*sPOv*1Uu~kw6Sp)|VccxZkB5cYl zhI$L=L4A;nzM-ChJ~nM7nQ1t*fn*@s!2W_*X9F_KDj>5WH7C*~GdDG_80a)RV*?wo zEf^9AcOq$wz@-sM0$rnXeolT-a6w{ns+}R!E+io&)gV_}`4?rT0s|BjY#`+rVo>!q z`k*jH3S&qFf<=KbXvbxv4^IttT)pl-5x@k};OXKRq9OV=*pcgi0?%s|_We%|vi~yL z|HSc5M}S1omE7x3gK~Q{Rc(X3(m5QxG#|~GEE<*lXz%nnn;VWuJnl-q=IFZU+OD-c z3(C22rv{#1c4oqx_w9EUzpiqc{J!o}ibdGV%Lg3R3rXp=R`?^JphDW&BUW54X{LkZh-mS@#xqF$e=oW1e?bFoy-G)%a?@ub*Sx0(wGZerUuRgx!=>( K&t;ucLK6Uk!f6Ts diff --git a/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage@3x.png b/Ifish/Assets.xcassets/绚多设备/normalImage.imageset/normalImage@3x.png deleted file mode 100644 index c893ff765e20e46d14841b721c3a3390029ae6d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 409 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S901SGegx)utg7>k44ofy`glX(f`xTHpSruq6Z zXaU(A42G$TlC0TWy{Y5_BX4N~Y?)4d(2jM>x0F{Fa= z?IlC50}2c*j%WY>&zYr=Bm72ITRcZ5kEflXQMqwv{MxPG{%$)xXa3>h+vorP?^d?6 zC~#3ol(kTruz^oT&?ADqk3(e*vpb8>wMJzo&esP78(T^rbT}Nc8qCTLDRKx{h*U7% WkYZlJy*B_T`%5<)m5J85}ytD(MF|E`^*N$e^xnJ96N?Hlv-HVyu#w4EkX1T5bJh}qV+XwiCrruY8Jqh4j13-QS zaM3&Za92UczNuH*ng&-&tYX_IHX@>T#abDnMn4v!WAQj)c)hq_jko31SyEqB`# zBio}aP$C&s+YAjpvO7*7M+ISkkWr^*BJcx9_@E%@T8&?IeUrZ?N}?nbIiBYgztxuO z>g|M%r-HB>hMr7Fx7!uFE28V~kZeAmCsK~&av4Nqf`?9ML>VWz90&OuM>T_{Z+W5R zIy{YQY`c45K@e!7;fm`tBWsk&36i$3K|(zwD@x>lw9smwLZhCTHs~u(r_f+>&5F#< zmTK9i6JTk@6-gOnIpG-9IY!h^BaS)#C9b+1*T3f(O|zIya*dhB(6nm#j&GSbP&zgW zKVeJo3ZXL{n{j-B11sKOkyFU@eLG^LNesfrv e{rCyemzXK|a)C{s{l55=zNX5p4fXBK#*;s3)8O*} literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1SGcvS$+jljKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uw}2VJ1}Qw{XwC|xY&~5ZLp*rj zUQ!eS8p!1M^?&`fjd9Cmd!249%-(J^^URy|R=m-UER77S_yt**R@k`+a4h&G;Hc0b bRda%|bt041$L*ooAOk&J{an^LB{Ts5Bg8GJ diff --git a/Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@2x.png b/Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@2x.png deleted file mode 100644 index d09f99871f19ee647faa3d00c60024c90b5ad934..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 314 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1SGf4^HT*L`q$Ofs&h>^zEm^x&6*Tu znW&R_ATaonmU@pWuSJ$u)YF!YOBmgKJy*{$m}c@|g=Xed;bW87WK31p79EPX)UbHj sl2AVhZ>fSSQ?{JqO!j0Z+7LId`1#pPWpkU4-3Gba)78&qol`;+03nWHssI20 diff --git a/Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@3x.png b/Ifish/Assets.xcassets/绚多设备/selectedImage.imageset/selectedImage@3x.png deleted file mode 100644 index 2c9c96b31439cefda6d7eb34368faca56daaafb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S901SGegx)utg7>k44ofy`glX(f`xTHpSruq6Z zXaU(A42G$TlC0TWy{Y5_BX4N~Y?)4d%?{q=Nl45?sz zdubytg8~nWVZ#5p%^Dhc?3Y{e*WS)ftBil}r~fxg!4hT}3#ADQ`D6r71hDsUq^w|e zXED0csLUk!>VRM)Pw9gWhc>GM7X@e8p`%P$MtpM))23@Z_G`ca;_BzJ&MBb@0Qe_y AQvd(} diff --git a/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.h b/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.h new file mode 100644 index 0000000..e8cde99 --- /dev/null +++ b/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.h @@ -0,0 +1,38 @@ +// +// UIButton+ImageTitleStyle.h +// +// Created by 欧阳大哥 on 14-7-13. +// QQ:156355113 +// Github: https://github.com/youngsoft +// Email: obq0387_cn@sina.com +// + +#import + +/* + 针对同时设置了Image和Title的场景时UIButton中的图片和文字的关系 + */ +typedef NS_ENUM(NSInteger, ButtonImageTitleStyle ) { + ButtonImageTitleStyleDefault = 0, //图片在左,文字在右,整体居中。 + ButtonImageTitleStyleLeft = 0, //图片在左,文字在右,整体居中。 + ButtonImageTitleStyleRight = 2, //图片在右,文字在左,整体居中。 + ButtonImageTitleStyleTop = 3, //图片在上,文字在下,整体居中。 + ButtonImageTitleStyleBottom = 4, //图片在下,文字在上,整体居中。 + ButtonImageTitleStyleCenterTop = 5, //图片居中,文字在上距离按钮顶部。 + ButtonImageTitleStyleCenterBottom = 6, //图片居中,文字在下距离按钮底部。 + ButtonImageTitleStyleCenterUp = 7, //图片居中,文字在图片上面。 + ButtonImageTitleStyleCenterDown = 8, //图片居中,文字在图片下面。 + ButtonImageTitleStyleRightLeft = 9, //图片在右,文字在左,距离按钮两边边距 + ButtonImageTitleStyleLeftRight = 10, //图片在左,文字在右,距离按钮两边边距 +}; + +@interface UIButton (ImageTitleStyle) + +/* + 调整按钮的文本和image的布局,前提是title和image同时存在才会调整。 + padding是调整布局时整个按钮和图文的间隔。 + + */ +-(void)setButtonImageTitleStyle:(ButtonImageTitleStyle)style padding:(CGFloat)padding; + +@end diff --git a/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.m b/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.m new file mode 100644 index 0000000..a6cf9ea --- /dev/null +++ b/Ifish/Utinitys/Category/UIButton+ImageTitleStyle.m @@ -0,0 +1,185 @@ +// +// UIButton+ImageTitleStyle.m +// +// Created by 欧阳大哥 on 14-7-13. +// + +#import "UIButton+ImageTitleStyle.h" + +@implementation UIButton (ImageTitleStyle) + +-(void)setButtonImageTitleStyle:(ButtonImageTitleStyle)style padding:(CGFloat)padding +{ + if (self.imageView.image != nil && self.titleLabel.text != nil) + { + + //先还原 + self.titleEdgeInsets = UIEdgeInsetsZero; + self.imageEdgeInsets = UIEdgeInsetsZero; + + CGRect imageRect = self.imageView.frame; + CGRect titleRect = self.titleLabel.frame; + + CGFloat totalHeight = imageRect.size.height + padding + titleRect.size.height; + CGFloat selfHeight = self.frame.size.height; + CGFloat selfWidth = self.frame.size.width; + + switch (style) { + case ButtonImageTitleStyleLeft: + if (padding != 0) + { + self.titleEdgeInsets = UIEdgeInsetsMake(0, + padding/2, + 0, + -padding/2); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + -padding/2, + 0, + padding/2); + } + break; + case ButtonImageTitleStyleRight: + { + //图片在右,文字在左 + self.titleEdgeInsets = UIEdgeInsetsMake(0, + -(imageRect.size.width + padding/2), + 0, + (imageRect.size.width + padding/2)); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (titleRect.size.width+ padding/2), + 0, + -(titleRect.size.width+ padding/2)); + } + break; + case ButtonImageTitleStyleTop: + { + //图片在上,文字在下 + self.titleEdgeInsets = UIEdgeInsetsMake(((selfHeight - totalHeight)/2 + imageRect.size.height + padding - titleRect.origin.y), + (selfWidth/2 - titleRect.origin.x - titleRect.size.width /2) - (selfWidth - titleRect.size.width) / 2, + -((selfHeight - totalHeight)/2 + imageRect.size.height + padding - titleRect.origin.y), + -(selfWidth/2 - titleRect.origin.x - titleRect.size.width /2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(((selfHeight - totalHeight)/2 - imageRect.origin.y), + (selfWidth /2 - imageRect.origin.x - imageRect.size.width / 2), + -((selfHeight - totalHeight)/2 - imageRect.origin.y), + -(selfWidth /2 - imageRect.origin.x - imageRect.size.width / 2)); + + } + break; + case ButtonImageTitleStyleBottom: + { + //图片在下,文字在上。 + self.titleEdgeInsets = UIEdgeInsetsMake(((selfHeight - totalHeight)/2 - titleRect.origin.y), + (selfWidth/2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2, + -((selfHeight - totalHeight)/2 - titleRect.origin.y), + -(selfWidth/2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(((selfHeight - totalHeight)/2 + titleRect.size.height + padding - imageRect.origin.y), + (selfWidth /2 - imageRect.origin.x - imageRect.size.width / 2), + -((selfHeight - totalHeight)/2 + titleRect.size.height + padding - imageRect.origin.y), + -(selfWidth /2 - imageRect.origin.x - imageRect.size.width / 2)); + } + break; + case ButtonImageTitleStyleCenterTop: + { + self.titleEdgeInsets = UIEdgeInsetsMake(-(titleRect.origin.y - padding), + (selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2, + (titleRect.origin.y - padding), + -(selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2), + 0, + -(selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2)); + } + break; + case ButtonImageTitleStyleCenterBottom: + { + self.titleEdgeInsets = UIEdgeInsetsMake((selfHeight - padding - titleRect.origin.y - titleRect.size.height), + (selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2, + -(selfHeight - padding - titleRect.origin.y - titleRect.size.height), + -(selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2), + 0, + -(selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2)); + } + break; + case ButtonImageTitleStyleCenterUp: + { + self.titleEdgeInsets = UIEdgeInsetsMake(-(titleRect.origin.y + titleRect.size.height - imageRect.origin.y + padding), + (selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2, + (titleRect.origin.y + titleRect.size.height - imageRect.origin.y + padding), + -(selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2), + 0, + -(selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2)); + } + break; + case ButtonImageTitleStyleCenterDown: + { + self.titleEdgeInsets = UIEdgeInsetsMake((imageRect.origin.y + imageRect.size.height - titleRect.origin.y + padding), + (selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2, + -(imageRect.origin.y + imageRect.size.height - titleRect.origin.y + padding), + -(selfWidth / 2 - titleRect.origin.x - titleRect.size.width / 2) - (selfWidth - titleRect.size.width) / 2); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2), + 0, + -(selfWidth / 2 - imageRect.origin.x - imageRect.size.width / 2)); + } + break; + case ButtonImageTitleStyleRightLeft: + { + //图片在右,文字在左,距离按钮两边边距 + + self.titleEdgeInsets = UIEdgeInsetsMake(0, + -(titleRect.origin.x - padding), + 0, + (titleRect.origin.x - padding)); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth - padding - imageRect.origin.x - imageRect.size.width), + 0, + -(selfWidth - padding - imageRect.origin.x - imageRect.size.width)); + } + + break; + + case ButtonImageTitleStyleLeftRight: + { + //图片在左,文字在右,距离按钮两边边距 + + self.titleEdgeInsets = UIEdgeInsetsMake(0, + (selfWidth - padding - titleRect.origin.x - titleRect.size.width), + 0, + -(selfWidth - padding - titleRect.origin.x - titleRect.size.width)); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, + -(imageRect.origin.x - padding), + 0, + (imageRect.origin.x - padding)); + + + + } + break; + default: + break; + } + } + else { + self.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0); + self.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0); + } + +} + + +@end + diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.h index 064e8b9..8ffae0a 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.h @@ -7,14 +7,23 @@ // #import +#import "UIButton+ImageTitleStyle.h" NS_ASSUME_NONNULL_BEGIN +@class TimerTypeTableViewCell; +@protocol TimerTypeTableViewCellDelegate +-(void)clickCell:(TimerTypeTableViewCell*)cell button:(UIButton*)button timerType:(NSInteger*)type; + +@end @interface TimerTypeTableViewCell : UITableViewCell -@property (weak, nonatomic) IBOutlet UIButton *timerbtn; -@property (weak, nonatomic) IBOutlet UIButton *recoverybtn; -@property (weak, nonatomic) IBOutlet UIButton *cyclebtn; +@property (strong, nonatomic) UIButton *timerbtn; +@property (strong, nonatomic) UIButton *recoverybtn; +@property (strong, nonatomic) UIButton *cyclebtn; +@property (nonatomic, strong) UIImageView *backImageView; +@property (nonatomic, weak) id delegate; + @end diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.m index 29d1387..d73635b 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.m @@ -10,16 +10,58 @@ @implementation TimerTypeTableViewCell +-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) + { + + UIImageView*imageView=[[UIImageView alloc]init]; + imageView.image=[UIImage imageNamed:@"ifishSetCell_back"]; + self.backImageView=imageView; + self.backgroundView=imageView; + + UIFont*font=[UIFont systemFontOfSize:16]; + UIButton*timerBtn=[UIButton buttonWithType:UIButtonTypeCustom]; + [timerBtn setTitle:@"定时模式" forState:UIControlStateNormal]; + [timerBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal]; + [timerBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected]; + timerBtn.tag=1; + timerBtn.titleLabel.font=font; + [timerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [timerBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; + self.timerbtn=timerBtn; + + UIButton*cycleBtn=[UIButton buttonWithType:UIButtonTypeCustom]; + [cycleBtn setTitle:@"循环模式" forState:UIControlStateNormal]; + [cycleBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal]; + [cycleBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected]; + cycleBtn.titleLabel.font=font; + [cycleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + cycleBtn.tag=2; + [cycleBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; + self.cyclebtn=cycleBtn; + + UIButton*recoveryBtn=[UIButton buttonWithType:UIButtonTypeCustom]; + [recoveryBtn setTitle:@"自恢复模式" forState:UIControlStateNormal]; + [recoveryBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal]; + [recoveryBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected]; + recoveryBtn.tag=3; + recoveryBtn.titleLabel.font=font; + [recoveryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [recoveryBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; + self.recoverybtn=recoveryBtn; + + [self.contentView addSubview:self.timerbtn]; + [self.contentView addSubview:self.cyclebtn]; + [self.contentView addSubview:self.recoverybtn]; + } + return self; +} - (void)awakeFromNib { [super awakeFromNib]; // Initialization code - [self.timerbtn mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(0); - make.top.mas_equalTo(0); - make.bottom.mas_equalTo(0); - make.width.mas_equalTo(120); }]; - self.timerbtn.titleEdgeInsets=UIEdgeInsetsMake(10, -90, 10, 0); - self.timerbtn.titleLabel.font=[UIFont systemFontOfSize:15]; + } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { @@ -27,5 +69,24 @@ // Configure the view for the selected state } - +-(void)layoutSubviews +{ + [super layoutSubviews]; + CGFloat width=self.frame.size.width/3.0; + CGFloat height=self.frame.size.height; + self.timerbtn.frame=CGRectMake(0, 0, width, height); + self.cyclebtn.frame=CGRectMake(width, 0, width, height); + self.recoverybtn.frame=CGRectMake(width*2, 0, width, height); + [self.timerbtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0]; + [self.cyclebtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0]; + [self.recoverybtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:0]; + +} +-(void)btnClicked:(UIButton*)button +{ + if ([self.delegate respondsToSelector:@selector(clickCell:button:timerType:)]) + { + [self.delegate clickCell:self button:button timerType:button.tag]; + } +} @end diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.xib b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.xib index 80afe29..0e95195 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.xib +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/TimerTypeTableViewCell.xib @@ -16,40 +16,9 @@ - - - - - - - - - - - - - diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.h index 9ea319a..53a084d 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2SettingController.h @@ -9,6 +9,8 @@ #import "FatherController.h" #import "IfishDeviceInfo.h" #include "xuanduo3fModel.h" +#import "ReadTimerModel.h" + NS_ASSUME_NONNULL_BEGIN @@ -19,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,strong) UIActivityIndicatorView*indicatorView; @property (nonatomic ,strong) id dataModel; @property(nonatomic,strong) DeviceModel* currentdevice; +@property (nonatomic, strong) ReadTimerModel *readMode; - (void)refreshWithData:(id)model; diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h index 91e4121..b0bc701 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h @@ -55,4 +55,13 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface XuanduoRecoveryModel : NSObject + +/// 灯的序号 +@property (nonatomic, strong) NSString *lightNumber; +@property (nonatomic, strong) NSString *lastTime; +@property (nonatomic, strong) NSString *gapTime; +@property (nonatomic, strong) NSString *status; + +@end NS_ASSUME_NONNULL_END diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h index 69e80cb..73db194 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h @@ -9,6 +9,7 @@ #import "FatherController.h" #import "IfishDeviceInfo.h" #include "xuanduo3fModel.h" +#import "ReadTimerModel.h" NS_ASSUME_NONNULL_BEGIN @@ -19,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,strong) UIActivityIndicatorView*indicatorView; @property (nonatomic ,strong) id dataModel; @property(nonatomic,strong) DeviceModel* currentdevice; - +@property (nonatomic, strong) ReadTimerModel *readMode; - (void)refreshWithData:(id)model; @end diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m index 4dfcafc..5d9ca29 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m @@ -41,7 +41,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; -@interface XuanduoTimerSettingViewController () +@interface XuanduoTimerSettingViewController () @property(nonatomic,strong) setRemindWaterModel *waterInfmodel; @property(nonatomic,strong) Xuanduo2TimerModel *timerModel; @property(nonatomic,strong) XuanduoCycleModel *cycleModel; @@ -154,10 +154,14 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; [self.tableView registerNib:[UINib nibWithNibName:temperatureCellid bundle:nil] forCellReuseIdentifier:temperatureCellid]; [self.tableView registerNib:[UINib nibWithNibName:changeWaterCellid bundle:nil] forCellReuseIdentifier:changeWaterCellid]; [self.tableView registerNib:[UINib nibWithNibName:addCellid bundle:nil] forCellReuseIdentifier:addCellid]; - [self.tableView registerNib:[UINib nibWithNibName:timerTypeFlag bundle:nil] forCellReuseIdentifier:timerTypeFlag]; + //[self.tableView registerNib:[UINib nibWithNibName:timerTypeFlag bundle:nil] forCellReuseIdentifier:timerTypeFlag]; [self.tableView registerNib:[UINib nibWithNibName:setTimerflag bundle:nil] forCellReuseIdentifier:setTimerflag]; } +-(void)clickCell:(TimerTypeTableViewCell *)cell button:(UIButton *)button timerType:(NSInteger *)type +{ + +} #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -322,7 +326,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section-2]]; BOOL havePlus = [dataArr containsObject:plusflag]; if (havePlus && (indexPath.row == dataArr.count-1)) { - TimerTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:timerTypeFlag forIndexPath:indexPath]; + TimerTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:timerTypeFlag]; + if (!cell) { + cell=[[TimerTypeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:timerTypeFlag]; + } return cell; }else { @@ -589,6 +596,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; _selectSection = btn.tag - kBtnTag; ReadTimerModel *readModel = [[ReadTimerModel alloc] init]; //杀菌不定时 + readModel.selectorName=_titieArr[_selectSection - 2]; if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2) { readModel.functionCode=@"19";//读取 @@ -637,6 +645,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str]; NSData*readData=[dataContorl stringToHexData:readString]; [[Socketsingleton sharedInstance] soketWriteData:readData]; + self.readMode=readModel; [_indicatorView startAnimating]; } } diff --git a/Ifish/models/wifiModel/sendmaseegemodel/ReadTimerModel.h b/Ifish/models/wifiModel/sendmaseegemodel/ReadTimerModel.h index c1404a3..7751e8f 100644 --- a/Ifish/models/wifiModel/sendmaseegemodel/ReadTimerModel.h +++ b/Ifish/models/wifiModel/sendmaseegemodel/ReadTimerModel.h @@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ReadTimerModel : baseModel /// 灯编号 +@property(nonatomic,copy)NSString*selectorName; @property(nonatomic,copy)NSString*selectorNumber; @property(nonatomic,copy)NSString*crc16str;