不同模式的选择
|
|
@ -2284,6 +2284,8 @@
|
||||||
C02D9E562794011300BBBF8D /* AlicloudHttpDNS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02D9E4F2794011100BBBF8D /* AlicloudHttpDNS.framework */; };
|
C02D9E562794011300BBBF8D /* AlicloudHttpDNS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02D9E4F2794011100BBBF8D /* AlicloudHttpDNS.framework */; };
|
||||||
C02ED596249E3B7300CAC37D /* InfoByImageViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */; };
|
C02ED596249E3B7300CAC37D /* InfoByImageViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */; };
|
||||||
C02ED597249E3B7300CAC37D /* InfoByImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */; };
|
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 */; };
|
C072196A253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */; };
|
||||||
C072196D253B1F4F0065CF17 /* DatePickerCustomView.h in Headers */ = {isa = PBXBuildFile; fileRef = C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */; };
|
C072196D253B1F4F0065CF17 /* DatePickerCustomView.h in Headers */ = {isa = PBXBuildFile; fileRef = C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */; };
|
||||||
C072196E253B1F4F0065CF17 /* DatePickerCustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */; };
|
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 = "<group>"; };
|
C02D9E4F2794011100BBBF8D /* AlicloudHttpDNS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AlicloudHttpDNS.framework; sourceTree = "<group>"; };
|
||||||
C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoByImageViewController.h; sourceTree = "<group>"; };
|
C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoByImageViewController.h; sourceTree = "<group>"; };
|
||||||
C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoByImageViewController.m; sourceTree = "<group>"; };
|
C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoByImageViewController.m; sourceTree = "<group>"; };
|
||||||
|
C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIButton+ImageTitleStyle.h"; sourceTree = "<group>"; };
|
||||||
|
C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIButton+ImageTitleStyle.m"; sourceTree = "<group>"; };
|
||||||
C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IfishP2PPlayBackListViewController.xib; sourceTree = "<group>"; };
|
C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IfishP2PPlayBackListViewController.xib; sourceTree = "<group>"; };
|
||||||
C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatePickerCustomView.h; sourceTree = "<group>"; };
|
C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatePickerCustomView.h; sourceTree = "<group>"; };
|
||||||
C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatePickerCustomView.m; sourceTree = "<group>"; };
|
C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatePickerCustomView.m; sourceTree = "<group>"; };
|
||||||
|
|
@ -12398,6 +12402,8 @@
|
||||||
C0C4CCFD272CDF4A00574BE8 /* UIViewController+Navgation.m */,
|
C0C4CCFD272CDF4A00574BE8 /* UIViewController+Navgation.m */,
|
||||||
C017B1E0245ED2D3003151DF /* UIImage+WaterMark.h */,
|
C017B1E0245ED2D3003151DF /* UIImage+WaterMark.h */,
|
||||||
C017B1E1245ED2D4003151DF /* UIImage+WaterMark.m */,
|
C017B1E1245ED2D4003151DF /* UIImage+WaterMark.m */,
|
||||||
|
C057166A282376CC004F113A /* UIButton+ImageTitleStyle.h */,
|
||||||
|
C057166B282376CC004F113A /* UIButton+ImageTitleStyle.m */,
|
||||||
);
|
);
|
||||||
path = Category;
|
path = Category;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|
@ -13057,6 +13063,7 @@
|
||||||
3D1C50BA221A9EE00096AE43 /* NetManager.h in Headers */,
|
3D1C50BA221A9EE00096AE43 /* NetManager.h in Headers */,
|
||||||
C0E7D6D023A1D16D00256A10 /* Constant.h in Headers */,
|
C0E7D6D023A1D16D00256A10 /* Constant.h in Headers */,
|
||||||
CB484DF622B8C8C80075F050 /* eval.h in Headers */,
|
CB484DF622B8C8C80075F050 /* eval.h in Headers */,
|
||||||
|
C057166C282376CC004F113A /* UIButton+ImageTitleStyle.h in Headers */,
|
||||||
3D1C513A221A9EE10096AE43 /* FishControlFirstCell.h in Headers */,
|
3D1C513A221A9EE10096AE43 /* FishControlFirstCell.h in Headers */,
|
||||||
3D1C50EC221A9EE00096AE43 /* MessageDAO.h in Headers */,
|
3D1C50EC221A9EE00096AE43 /* MessageDAO.h in Headers */,
|
||||||
CB484DF322B8C8C80075F050 /* timecode.h in Headers */,
|
CB484DF322B8C8C80075F050 /* timecode.h in Headers */,
|
||||||
|
|
@ -15380,6 +15387,7 @@
|
||||||
8864841F1EE166A40046C3BD /* RuSunChangeNameTextViewCell.m in Sources */,
|
8864841F1EE166A40046C3BD /* RuSunChangeNameTextViewCell.m in Sources */,
|
||||||
88779EAB1E28999600209ABA /* JuNengCCSetViewController.m in Sources */,
|
88779EAB1E28999600209ABA /* JuNengCCSetViewController.m in Sources */,
|
||||||
883E762A1D4897570030E075 /* merchantModel.m in Sources */,
|
883E762A1D4897570030E075 /* merchantModel.m in Sources */,
|
||||||
|
C057166D282376CC004F113A /* UIButton+ImageTitleStyle.m in Sources */,
|
||||||
883E78451D48A5E50030E075 /* KeLiAiCenterViewController.m in Sources */,
|
883E78451D48A5E50030E075 /* KeLiAiCenterViewController.m in Sources */,
|
||||||
883E76231D4897570030E075 /* MyChatRoomModel.m in Sources */,
|
883E76231D4897570030E075 /* MyChatRoomModel.m in Sources */,
|
||||||
883E78551D48A5E50030E075 /* TwoControlSetTimeViewController.m in Sources */,
|
883E78551D48A5E50030E075 /* TwoControlSetTimeViewController.m in Sources */,
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,10 @@
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "normalImage@2x.png",
|
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "normalImage@3x.png",
|
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 322 B |
|
Before Width: | Height: | Size: 409 B |
|
|
@ -6,12 +6,10 @@
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "selectedImage@2x.png",
|
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "selectedImage@3x.png",
|
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "3x"
|
"scale" : "3x"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 886 B |
|
Before Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 403 B |
|
|
@ -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 <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
针对同时设置了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
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
@ -7,14 +7,23 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "UIButton+ImageTitleStyle.h"
|
||||||
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
@class TimerTypeTableViewCell;
|
||||||
|
@protocol TimerTypeTableViewCellDelegate <NSObject>
|
||||||
|
|
||||||
|
-(void)clickCell:(TimerTypeTableViewCell*)cell button:(UIButton*)button timerType:(NSInteger*)type;
|
||||||
|
|
||||||
|
@end
|
||||||
@interface TimerTypeTableViewCell : UITableViewCell
|
@interface TimerTypeTableViewCell : UITableViewCell
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *timerbtn;
|
@property (strong, nonatomic) UIButton *timerbtn;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *recoverybtn;
|
@property (strong, nonatomic) UIButton *recoverybtn;
|
||||||
@property (weak, nonatomic) IBOutlet UIButton *cyclebtn;
|
@property (strong, nonatomic) UIButton *cyclebtn;
|
||||||
|
@property (nonatomic, strong) UIImageView *backImageView;
|
||||||
|
@property (nonatomic, weak) id <TimerTypeTableViewCellDelegate>delegate;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,58 @@
|
||||||
|
|
||||||
@implementation TimerTypeTableViewCell
|
@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 {
|
- (void)awakeFromNib {
|
||||||
[super awakeFromNib];
|
[super awakeFromNib];
|
||||||
// Initialization code
|
// 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 {
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||||
|
|
@ -27,5 +69,24 @@
|
||||||
|
|
||||||
// Configure the view for the selected state
|
// 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
|
@end
|
||||||
|
|
|
||||||
|
|
@ -16,40 +16,9 @@
|
||||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N2e-hF-SlL" userLabel="timerbtn">
|
|
||||||
<rect key="frame" x="10" y="2" width="136" height="35"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
|
||||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
|
||||||
<state key="normal" title="Button"/>
|
|
||||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="定时模式" titleAlignment="automatic"/>
|
|
||||||
</button>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xbU-qP-hXX" userLabel="recoverybtn">
|
|
||||||
<rect key="frame" x="203" y="-2" width="136" height="35"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
|
||||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
|
||||||
<state key="normal" title="Button"/>
|
|
||||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="自恢复模式" titleAlignment="automatic"/>
|
|
||||||
</button>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yqV-t4-x09" userLabel="cyclebtn">
|
|
||||||
<rect key="frame" x="113" y="5" width="136" height="35"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
|
||||||
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
|
||||||
<state key="normal" title="Button"/>
|
|
||||||
<buttonConfiguration key="configuration" style="plain" image="selectedImage" title="循环模式" titleAlignment="automatic"/>
|
|
||||||
</button>
|
|
||||||
</subviews>
|
|
||||||
</tableViewCellContentView>
|
</tableViewCellContentView>
|
||||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||||
<connections>
|
|
||||||
<outlet property="cyclebtn" destination="yqV-t4-x09" id="Ptm-mX-wAk"/>
|
|
||||||
<outlet property="recoverybtn" destination="xbU-qP-hXX" id="AG5-Cy-9Th"/>
|
|
||||||
<outlet property="timerbtn" destination="N2e-hF-SlL" id="6Nb-dL-mwl"/>
|
|
||||||
</connections>
|
|
||||||
<point key="canvasLocation" x="137.68115942028987" y="68.973214285714278"/>
|
<point key="canvasLocation" x="137.68115942028987" y="68.973214285714278"/>
|
||||||
</tableViewCell>
|
</tableViewCell>
|
||||||
</objects>
|
</objects>
|
||||||
<resources>
|
|
||||||
<image name="selectedImage" width="30" height="30"/>
|
|
||||||
</resources>
|
|
||||||
</document>
|
</document>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#import "FatherController.h"
|
#import "FatherController.h"
|
||||||
#import "IfishDeviceInfo.h"
|
#import "IfishDeviceInfo.h"
|
||||||
#include "xuanduo3fModel.h"
|
#include "xuanduo3fModel.h"
|
||||||
|
#import "ReadTimerModel.h"
|
||||||
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
|
@ -19,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
||||||
@property (nonatomic ,strong) id dataModel;
|
@property (nonatomic ,strong) id dataModel;
|
||||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||||
|
@property (nonatomic, strong) ReadTimerModel *readMode;
|
||||||
|
|
||||||
- (void)refreshWithData:(id)model;
|
- (void)refreshWithData:(id)model;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@end
|
@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
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#import "FatherController.h"
|
#import "FatherController.h"
|
||||||
#import "IfishDeviceInfo.h"
|
#import "IfishDeviceInfo.h"
|
||||||
#include "xuanduo3fModel.h"
|
#include "xuanduo3fModel.h"
|
||||||
|
#import "ReadTimerModel.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
|
@ -19,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
@property (nonatomic,strong) UIActivityIndicatorView*indicatorView;
|
||||||
@property (nonatomic ,strong) id dataModel;
|
@property (nonatomic ,strong) id dataModel;
|
||||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||||
|
@property (nonatomic, strong) ReadTimerModel *readMode;
|
||||||
- (void)refreshWithData:(id)model;
|
- (void)refreshWithData:(id)model;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface XuanduoTimerSettingViewController ()<IfishCommuniteDelegate>
|
@interface XuanduoTimerSettingViewController ()<IfishCommuniteDelegate,TimerTypeTableViewCellDelegate>
|
||||||
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
|
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
|
||||||
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
|
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
|
||||||
@property(nonatomic,strong) XuanduoCycleModel *cycleModel;
|
@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:temperatureCellid bundle:nil] forCellReuseIdentifier:temperatureCellid];
|
||||||
[self.tableView registerNib:[UINib nibWithNibName:changeWaterCellid bundle:nil] forCellReuseIdentifier:changeWaterCellid];
|
[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: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];
|
[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
|
#pragma mark - Table view data source
|
||||||
|
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||||
|
|
@ -322,7 +326,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||||
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section-2]];
|
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section-2]];
|
||||||
BOOL havePlus = [dataArr containsObject:plusflag];
|
BOOL havePlus = [dataArr containsObject:plusflag];
|
||||||
if (havePlus && (indexPath.row == dataArr.count-1)) {
|
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;
|
return cell;
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -589,6 +596,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||||
_selectSection = btn.tag - kBtnTag;
|
_selectSection = btn.tag - kBtnTag;
|
||||||
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
|
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
|
||||||
//杀菌不定时
|
//杀菌不定时
|
||||||
|
readModel.selectorName=_titieArr[_selectSection - 2];
|
||||||
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
|
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
|
||||||
{
|
{
|
||||||
readModel.functionCode=@"19";//读取
|
readModel.functionCode=@"19";//读取
|
||||||
|
|
@ -637,6 +645,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
|
||||||
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
|
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
|
||||||
NSData*readData=[dataContorl stringToHexData:readString];
|
NSData*readData=[dataContorl stringToHexData:readString];
|
||||||
[[Socketsingleton sharedInstance] soketWriteData:readData];
|
[[Socketsingleton sharedInstance] soketWriteData:readData];
|
||||||
|
self.readMode=readModel;
|
||||||
[_indicatorView startAnimating];
|
[_indicatorView startAnimating];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@interface ReadTimerModel : baseModel
|
@interface ReadTimerModel : baseModel
|
||||||
|
|
||||||
/// 灯编号
|
/// 灯编号
|
||||||
|
@property(nonatomic,copy)NSString*selectorName;
|
||||||
@property(nonatomic,copy)NSString*selectorNumber;
|
@property(nonatomic,copy)NSString*selectorNumber;
|
||||||
@property(nonatomic,copy)NSString*crc16str;
|
@property(nonatomic,copy)NSString*crc16str;
|
||||||
|
|
||||||
|
|
|
||||||