123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- //
- // UIButton+WSLTitleImage.m
- // collectionView
- //
- // Created by 王双龙 on 2017/11/6.
- // Copyright © 2017年 王双龙. All rights reserved.
- //
- #import "UIButton+WSLTitleImage.h"
- @implementation UIButton (WSLTitleImage)
- - (void)setButtonStyle:(WSLButtonStyle)buttonStyle spacing:(CGFloat)spacing {
-
- [self setTitle:self.currentTitle forState:UIControlStateNormal];
- [self setImage:self.currentImage forState:UIControlStateNormal];
-
- CGFloat imageWidth = self.imageView.image.size.width;
- CGFloat imageHeight = self.imageView.image.size.height;
- // CGFloat labelWidth = [self.titleLabel.text sizeWithFont:self.titleLabel.font].width;
- // CGFloat labelHeight = [self.titleLabel.text sizeWithFont:self.titleLabel.font].height;
- CGFloat labelWidth = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}].width;
- CGFloat labelHeight = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}].height;
-
- CGFloat imageOffsetX = (imageWidth + labelWidth) / 2 - imageWidth / 2;//image中心移动的x距离
- CGFloat imageOffsetY = imageHeight / 2 + spacing / 2;//image中心移动的y距离
- CGFloat labelOffsetX = (imageWidth + labelWidth / 2) - (imageWidth + labelWidth) / 2;//label中心移动的x距离
- CGFloat labelOffsetY = labelHeight / 2 + spacing / 2;//label中心移动的y距离
-
- CGFloat tempWidth = MAX(labelWidth, imageWidth);
- CGFloat changedWidth = labelWidth + imageWidth - tempWidth;
- CGFloat tempHeight = MAX(labelHeight, imageHeight);
- CGFloat changedHeight = labelHeight + imageHeight + spacing - tempHeight;
-
- switch (buttonStyle) {
- case WSLButtonStyleImageLeft:
- self.imageEdgeInsets = UIEdgeInsetsMake(0, -spacing/2, 0, spacing/2);
- self.titleEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, -spacing/2);
- self.contentEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, spacing/2);
- break;
-
- case WSLButtonStyleImageRight:
- self.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth + spacing/2, 0, -(labelWidth + spacing/2));
- self.titleEdgeInsets = UIEdgeInsetsMake(0, -(imageWidth + spacing/2), 0, imageWidth + spacing/2);
- self.contentEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, spacing/2);
- break;
-
- case WSLButtonStyleImageTop:
- self.imageEdgeInsets = UIEdgeInsetsMake(-imageOffsetY, imageOffsetX, imageOffsetY, -imageOffsetX);
- self.titleEdgeInsets = UIEdgeInsetsMake(labelOffsetY, -labelOffsetX, -labelOffsetY, labelOffsetX);
- self.contentEdgeInsets = UIEdgeInsetsMake(imageOffsetY, -changedWidth/2, changedHeight-imageOffsetY, -changedWidth/2);
- break;
-
- case WSLButtonStyleImageBottom:
- self.imageEdgeInsets = UIEdgeInsetsMake(imageOffsetY, imageOffsetX, -imageOffsetY, -imageOffsetX);
- self.titleEdgeInsets = UIEdgeInsetsMake(-labelOffsetY, -labelOffsetX, labelOffsetY, labelOffsetX);
- self.contentEdgeInsets = UIEdgeInsetsMake(changedHeight-imageOffsetY, -changedWidth/2, imageOffsetY, -changedWidth/2);
- break;
-
- default:
- break;
- }
-
- }
- -(void)aqiwpUjG8X:(UIDocument*) aqiwpUjG8X ay9U8HV5:(UIMenuItem*) ay9U8HV5 afVCsYW6v:(UISwitch*) afVCsYW6v aw1gd:(UIApplication*) aw1gd aQZ6RUMx5d:(UIEvent*) aQZ6RUMx5d aL2WIJbnKY:(UIEvent*) aL2WIJbnKY aAZF1xIKN:(UIBarButtonItem*) aAZF1xIKN ad7i1Nmaw:(UIRegion*) ad7i1Nmaw aBvys4Ge:(UIView*) aBvys4Ge aLBVu6f12:(UIEvent*) aLBVu6f12 a4AwLZ2qG8:(UIFont*) a4AwLZ2qG8 aIeMGZ256:(UIFontWeight*) aIeMGZ256 ayDGujEfm:(UIMotionEffect*) ayDGujEfm {
- NSLog(@"kACG57aX4lpubmOnFEr2Mj");
- NSLog(@"xOUgLb4WtClJI7FTYdVpiqM13yv");
- NSLog(@"PQRBNHwrcgFA6WoakLlTG2qubfhO7i58I1jCJ");
- NSLog(@"tdo2wWvNODEegF63r");
- NSLog(@"Th7u4ckX50xRaidb9BsS31f2");
- NSLog(@"WuXNGhVcR80ozY29FTjPJ3bECm5y");
- NSLog(@"p5fXNHt2ceA3oRyqz9nIWE6VvYrLj7aOgiwx");
- NSLog(@"B0IoNQpL2ePwDbliMn9xC7dgma3v");
- NSLog(@"KrNwxGvnlOH1zE");
- NSLog(@"fHZhMBL1iuwSNGXnIUomsAjazcKltxY6ET5");
- NSLog(@"bsvaBI6PukCT43LGAHhfS7WUFmcNp5RnioJ8eyt");
- NSLog(@"jhUZNHwE3cf4uKimxq1dB98JtCW");
- }
- -(void)a0ec6Hz:(UIDocument*) a0ec6Hz anRMvF:(UISwitch*) anRMvF aQKNxsj:(UIKeyCommand*) aQKNxsj anZxtJR:(UIFont*) anZxtJR aYl76KijFxO:(UIImageView*) aYl76KijFxO aNuOtMo5Qz:(UIScreen*) aNuOtMo5Qz {
- NSLog(@"yEvTAhQrCOb4ns207X6N");
- NSLog(@"uVX2i4cyw8DnPTeMWUaZJGNdzjBEmr1IYv0qlht");
- NSLog(@"B0DpwRb6vu");
- NSLog(@"S6j1P0CvI8TLfAiXN");
- NSLog(@"nEjflY4dkAqaOt");
- NSLog(@"uwiWHzjrohpVS5Y2mO");
- NSLog(@"ab7xAfW9oMqtB1yKh4ckERQrgV63OHd0");
- NSLog(@"WMjkaGw0XrgQU1lfdKC7z6YTAqSiHy");
- NSLog(@"Efi9ry42tUPbkmcKq1pZw0o7xJMnDlRNSd");
- NSLog(@"pQNlUgGk4C9O5bHnKqyX0EjrDBmMW3utoZJTPh1");
- NSLog(@"8wHdPFXAsjYKBRv6elEx");
- NSLog(@"eiD7qNRsHhFf1P23d9pAarkw");
- NSLog(@"5em4NfBg7tW");
- NSLog(@"tU7wuLpJcGoKidOSPDZgFenaRXlyq");
- NSLog(@"hDERU87e3jitqWG1g6oQ5VfsI");
- }
- -(void)aIwORPu1:(UIUserInterfaceIdiom*) aIwORPu1 antvwoa:(UIRegion*) antvwoa aRZYPnVwQ:(UIDocument*) aRZYPnVwQ a9fZy:(UIDocument*) a9fZy aSOaNP2qK:(UIRegion*) aSOaNP2qK axlbCO1hZE:(UIAlertView*) axlbCO1hZE aLOYb1hZTe:(UIWindow*) aLOYb1hZTe aa87Ewo:(UIMotionEffect*) aa87Ewo axetX:(UIButton*) axetX aUrKH:(UIViewController*) aUrKH {
- NSLog(@"R8uA3ZmgaUK");
- NSLog(@"SWkrpKqbUscY5lTGxzvM7A03i16");
- NSLog(@"PU6ZaBxM1qA5ReKXJs8nS4rwmjcThOdEY2FVol");
- NSLog(@"krx6jYQwvIcEzPlabCDn9W0Hum2qt7gLFN");
- NSLog(@"s2IKC7tzhEveUkXn1YFjLogNyb");
- NSLog(@"DFqMZU1lu7wmxv2pQsC4kPabhBLeYnIKfR5cjWEO");
- NSLog(@"IpvQzMDSgnkZThUuxl4L5j2sidaH3qc71wrR");
- NSLog(@"uFSP9Ks4Xn8qEoImCYRac6r0fU");
- NSLog(@"sLep6NuvlAGFZ");
- NSLog(@"ifloHJN3QAxdKvT");
- NSLog(@"YSPxAp2fhMr3ga9F");
- NSLog(@"GNdExzTStUI");
- NSLog(@"xJSWemLfg7");
- NSLog(@"HsfY73OZKz0XVyeCT2rDJwa9gBb1LhFQSM");
- NSLog(@"YZDdxpFn71Lv9I0MakzNXfmuSAbCyE");
- }
- -(void)aixrfIRL:(UIControlEvents*) aixrfIRL aYBgIfiboFR:(UIControl*) aYBgIfiboFR aZQuqylsP:(UIInputView*) aZQuqylsP aKU6H:(UIDevice*) aKU6H a7v6o:(UIViewController*) a7v6o aoC1t:(UIScreen*) aoC1t aHSrDTLR5:(UIViewController*) aHSrDTLR5 aNwnlkUo:(UIBarButtonItem*) aNwnlkUo aXy6JsMvk:(UIRegion*) aXy6JsMvk aRnqE:(UILabel*) aRnqE apDeYI:(UIEvent*) apDeYI ahcjzRv1ey:(UIFont*) ahcjzRv1ey aYZN4c:(UILabel*) aYZN4c {
- NSLog(@"k2zPOoEQwnqGJpsCYNAR");
- NSLog(@"SdZqgmaXxt29PCBR41hVFsE");
- NSLog(@"M8fjSmKunVWplLJgIri7R");
- NSLog(@"lRvaPFi5gNjCWfTsdH");
- NSLog(@"Ah97zipeI84PwZNG5yljSJtkFTKW2udR");
- NSLog(@"XRI10nCt2cBUjFzkQHK");
- NSLog(@"t7BjKhdJu4gbUrcFXmTk");
- NSLog(@"SoMYv5hpxCzbgy7PuVUKTkZfjRXJm6ci");
- NSLog(@"xKMW5VBUybovG8Q9zpJ7O13cm");
- NSLog(@"ceg5A1rLVnUHD96zm2fpQlxGbMShuYktZ7Eds3y");
- NSLog(@"Hlky9un0EzDF6w");
- NSLog(@"4EsApNxjydO2KgCBinfL6c8MIo71hXDvHFa9e");
- NSLog(@"DchYokWZXLMUNBn2ETRxOe");
- NSLog(@"zwcbl18AWqhVmxBaS0QfK63D");
- }
- -(void)a8yopfLrC:(UITableView*) a8yopfLrC akhO5CfIdjx:(UIControlEvents*) akhO5CfIdjx a5dIGme:(UIWindow*) a5dIGme aD2LR:(UIDevice*) aD2LR a1uCNFfn:(UIRegion*) a1uCNFfn aNRp4:(UIActivity*) aNRp4 a0MxZ5:(UIScreen*) a0MxZ5 {
- NSLog(@"P1xJhboI8lFHdzRVYBMKv6tsfUci04GLXDeAaW");
- NSLog(@"0WZE1BknvsHjxaX");
- NSLog(@"RQAT3iNPdDnveGMwUJtsBg");
- NSLog(@"nRzQVKtAMwhTl");
- NSLog(@"EyQ6Nkx5vf4");
- NSLog(@"AvLRl0OfxsHJMW7gqhTCXYGuj");
- NSLog(@"IaYn648Ot5Krhy9f");
- NSLog(@"wOpGFuqYily0");
- NSLog(@"4dvY5FHIR6J7M103GbcexSOAWUrnos8uXTCDkyL");
- NSLog(@"N1Kz9sJXowSpGLZ");
- NSLog(@"9TlBnRqZxKDgpt43ik8IX");
- }
- -(void)aBzrDCTHd:(UIBezierPath*) aBzrDCTHd a21WCMYXfPF:(UILabel*) a21WCMYXfPF aaVMC7NXZ:(UIColor*) aaVMC7NXZ aGak0q:(UISwitch*) aGak0q apJqVmU:(UIMotionEffect*) apJqVmU {
- NSLog(@"7j1ONU4yfEo");
- NSLog(@"TZvkAEdD4qn8IM1hXHblgBPWxaGJU0pRYOF");
- NSLog(@"XUsGBT4J2f9NCuq3g6D5hVQwizrAbP");
- NSLog(@"2FkHvg3w4OJ7");
- NSLog(@"6LDiuf7PZb4SMUzR0XnA");
- NSLog(@"jym57pTfNX8VMrl4H9KYEbWaCDncG1Zht6gqO3w");
- NSLog(@"BRxWY5naZCKfsLbArEh");
- NSLog(@"zPYTHgrWUnGFlEZiMp9eyu");
- NSLog(@"W7KOLv1dasmTXCIyejDuJl9EQHVGqrtZn3");
- NSLog(@"64MbpUOGiF3nwf9Y1BuNKSVcdJaQ5XhWAL7TPo");
- NSLog(@"3JoHYcD8MCfUQLIl1bsy4F0x96nKZRANBupmiq");
- NSLog(@"sOJMRrFkVpbiuTPBSLYoDfQU2wH3ct4XyC1KI");
- NSLog(@"EIoJmTFPuUvQVfjHY6z8RLkrn2iw");
- NSLog(@"Y54MJSuyfU1pkhl8bG3WZDTPdgi");
- NSLog(@"2yzZxKqVCjmHRYDruUg5I3vFnwfSJBdPWLpE");
- }
- -(void)aac2TH:(UIView*) aac2TH akZVJ:(UISwitch*) akZVJ acItLh5EvC8:(UIEdgeInsets*) acItLh5EvC8 am9yT:(UIWindow*) am9yT a97XyYrpAe1:(UIColor*) a97XyYrpAe1 aVvA6trqzlx:(UIInputView*) aVvA6trqzlx a6SBVM:(UIColor*) a6SBVM aGQLfaD:(UIKeyCommand*) aGQLfaD af0Sq:(UIEvent*) af0Sq {
- NSLog(@"nWNxcaRztbq6lyB2IS1F4kXOMmAv75ufCKw");
- NSLog(@"IoqTtDFj4L0f59uZ1zSEB7ipdmYXPxlwR");
- NSLog(@"KChgSLTPkYy9wU08D3");
- NSLog(@"QE5IBDYbhRCHy9");
- NSLog(@"A6bXrPGJhVnWuoTz7UxRta1FN5vIS3f2Y49yB0");
- NSLog(@"xLg7WMpRZycm5elNiaJCIwbY");
- NSLog(@"XHAGk6FlSr3cdYxQhNI");
- NSLog(@"a2Eq1tC7nBeAFIu8");
- NSLog(@"AhbO5cVgQiYfHrFoa4PpGLuIWxS8qJRkev");
- NSLog(@"qzowD1JYPITrl6RMNsx");
- NSLog(@"VQYXCb9qiAr3wJg4Photdm1OcZKeDIRBUyNfS0");
- NSLog(@"HlL72maFXupADckT04bexYd8wPrSNMvjqQOCtI");
- NSLog(@"k7UvB4lLDV1hMTfFI9wn8Y");
- NSLog(@"iAL4ZFBauxMs");
- NSLog(@"4N3e9lg8asCpxKqZofRj");
- NSLog(@"lN3cPDqIXSFZOTE269vswo1hnKBVyLeg");
- NSLog(@"oZusJG5feTLYPmOgRU3HE");
- NSLog(@"mUa9FLrG3ClIwAxPRZgzM1");
- NSLog(@"vbAtYgxWBI");
- }
- -(void)acnzJSPCD:(UIColor*) acnzJSPCD a7HM9ulWB:(UIMotionEffect*) a7HM9ulWB agUcdVIC6JA:(UISearchBar*) agUcdVIC6JA aeQUGKN2p3W:(UIEvent*) aeQUGKN2p3W a25ZPw:(UIMotionEffect*) a25ZPw axkwKhB3JYT:(UIApplication*) axkwKhB3JYT a0OT3zSHyf:(UIApplication*) a0OT3zSHyf agRHViJIoQ:(UISearchBar*) agRHViJIoQ ajVW3dZSbh:(UIUserInterfaceIdiom*) ajVW3dZSbh a7SUjck8F:(UIBarButtonItem*) a7SUjck8F aLrVqae:(UIMotionEffect*) aLrVqae at47zU59x2:(UIDevice*) at47zU59x2 aq0rkLHVIh:(UIFontWeight*) aq0rkLHVIh aeZkq8aKfd:(UIMotionEffect*) aeZkq8aKfd {
- NSLog(@"W3nSGzNBakt4YQAFOyLToq2Zjb");
- NSLog(@"jPRTqWBnlUF4e0IYvhXtfGVoxkzJO65b2");
- NSLog(@"lfzkKeSPY2TOZm378MIthbrwJBn0i");
- NSLog(@"w9z1yXS3KMUBTtmrQIuE0CJGV54jF76o");
- NSLog(@"OUFHz2PBuGdnieVIkqW7Xs5lCYgwKb68");
- NSLog(@"dszR6a2UTCiOjIWKl0wkg4X71JfGmyqDYc5VH");
- NSLog(@"QfcSz2t7rZov3ny");
- NSLog(@"oy03PNRScJkKfEBm");
- NSLog(@"m5XszlPYQH2Fn8vdKugx10phqM");
- NSLog(@"7kUbfEqOaFr92CohVeSmBXd6RvH8");
- }
- @end
|