No Description

UIButton+WSLTitleImage.m 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // UIButton+WSLTitleImage.m
  3. // collectionView
  4. //
  5. // Created by 王双龙 on 2017/11/6.
  6. // Copyright © 2017年 王双龙. All rights reserved.
  7. //
  8. #import "UIButton+WSLTitleImage.h"
  9. @implementation UIButton (WSLTitleImage)
  10. - (void)setButtonStyle:(WSLButtonStyle)buttonStyle spacing:(CGFloat)spacing {
  11. [self setTitle:self.currentTitle forState:UIControlStateNormal];
  12. [self setImage:self.currentImage forState:UIControlStateNormal];
  13. CGFloat imageWidth = self.imageView.image.size.width;
  14. CGFloat imageHeight = self.imageView.image.size.height;
  15. // CGFloat labelWidth = [self.titleLabel.text sizeWithFont:self.titleLabel.font].width;
  16. // CGFloat labelHeight = [self.titleLabel.text sizeWithFont:self.titleLabel.font].height;
  17. CGFloat labelWidth = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}].width;
  18. CGFloat labelHeight = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}].height;
  19. CGFloat imageOffsetX = (imageWidth + labelWidth) / 2 - imageWidth / 2;//image中心移动的x距离
  20. CGFloat imageOffsetY = imageHeight / 2 + spacing / 2;//image中心移动的y距离
  21. CGFloat labelOffsetX = (imageWidth + labelWidth / 2) - (imageWidth + labelWidth) / 2;//label中心移动的x距离
  22. CGFloat labelOffsetY = labelHeight / 2 + spacing / 2;//label中心移动的y距离
  23. CGFloat tempWidth = MAX(labelWidth, imageWidth);
  24. CGFloat changedWidth = labelWidth + imageWidth - tempWidth;
  25. CGFloat tempHeight = MAX(labelHeight, imageHeight);
  26. CGFloat changedHeight = labelHeight + imageHeight + spacing - tempHeight;
  27. switch (buttonStyle) {
  28. case WSLButtonStyleImageLeft:
  29. self.imageEdgeInsets = UIEdgeInsetsMake(0, -spacing/2, 0, spacing/2);
  30. self.titleEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, -spacing/2);
  31. self.contentEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, spacing/2);
  32. break;
  33. case WSLButtonStyleImageRight:
  34. self.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth + spacing/2, 0, -(labelWidth + spacing/2));
  35. self.titleEdgeInsets = UIEdgeInsetsMake(0, -(imageWidth + spacing/2), 0, imageWidth + spacing/2);
  36. self.contentEdgeInsets = UIEdgeInsetsMake(0, spacing/2, 0, spacing/2);
  37. break;
  38. case WSLButtonStyleImageTop:
  39. self.imageEdgeInsets = UIEdgeInsetsMake(-imageOffsetY, imageOffsetX, imageOffsetY, -imageOffsetX);
  40. self.titleEdgeInsets = UIEdgeInsetsMake(labelOffsetY, -labelOffsetX, -labelOffsetY, labelOffsetX);
  41. self.contentEdgeInsets = UIEdgeInsetsMake(imageOffsetY, -changedWidth/2, changedHeight-imageOffsetY, -changedWidth/2);
  42. break;
  43. case WSLButtonStyleImageBottom:
  44. self.imageEdgeInsets = UIEdgeInsetsMake(imageOffsetY, imageOffsetX, -imageOffsetY, -imageOffsetX);
  45. self.titleEdgeInsets = UIEdgeInsetsMake(-labelOffsetY, -labelOffsetX, labelOffsetY, labelOffsetX);
  46. self.contentEdgeInsets = UIEdgeInsetsMake(changedHeight-imageOffsetY, -changedWidth/2, imageOffsetY, -changedWidth/2);
  47. break;
  48. default:
  49. break;
  50. }
  51. }
  52. -(void)atvC7:(UIViewController*) atvC7 a1F8CVm:(UIMenuItem*) a1F8CVm amgxKrG3:(UIVisualEffectView*) amgxKrG3 atP5uj0L:(UIImageView*) atP5uj0L aB8FGyOLj:(UIControl*) aB8FGyOLj anYa8:(UIView*) anYa8 acjkGZ92Cn:(UIViewController*) acjkGZ92Cn aQEL6:(UIInputView*) aQEL6 a5GuVvlSWI:(UIView*) a5GuVvlSWI aZThBL:(UIMotionEffect*) aZThBL aw1aeBqXyd:(UIKeyCommand*) aw1aeBqXyd afaJpxEQX7y:(UIDocument*) afaJpxEQX7y a7AZ8LMRrfC:(UIBarButtonItem*) a7AZ8LMRrfC a7jKc:(UICollectionView*) a7jKc apGBF6PWvEJ:(UIBarButtonItem*) apGBF6PWvEJ {
  53. NSLog(@"pN308ghtAYbBisT2qJUmQRPXGv45dea1Hy7WLS6k");
  54. NSLog(@"0BsvrhufnDWZVljXgJ6TEK3AzcFxtMSoNCq");
  55. NSLog(@"36vZnYhgLReMb85qHKwXm2uj");
  56. NSLog(@"2QAUSyWMmz9rPFuDXGV1548fbKEsJ6Io0t");
  57. NSLog(@"bqedTfzhIlwRm8YJOQX5Ap2FZ1");
  58. NSLog(@"KlDfJQc9HAmrP6OTBGnix53bMseuy1V");
  59. NSLog(@"JKTFVte42I7hPOBXNomZUSM3fbn");
  60. NSLog(@"v5JKxOLj1V6m4ID0nwsgGC2ZrhpedEYk7Po");
  61. NSLog(@"RB0toUQkjKOHL2ny9h");
  62. NSLog(@"vLiI2rUMJNjKCf6nlouQRtpkmZcBW");
  63. NSLog(@"ofC3iduTjY1ncwDpVIS59FrsOUg4lWQ");
  64. NSLog(@"n5h6dRUebNlCywukfmMIo1q9Y");
  65. NSLog(@"B86Pt2OGp3jSvXqdAg9xiV5FYK");
  66. NSLog(@"OJ18DN2euT");
  67. NSLog(@"rLQgIMXFhxKE3aZY7iwn19b5V0G");
  68. NSLog(@"g9BnskJcDlYHy2jKCZRGMT1bL36wSrtav");
  69. NSLog(@"XHFhM5PlRBL");
  70. NSLog(@"HW6eyOuNVEtaJq3FTzZdIilcowMUDnRXQShx");
  71. }
  72. -(void)aivomHk:(UIFont*) aivomHk aZndDKXPC:(UIScreen*) aZndDKXPC auAq3xF4:(UIKeyCommand*) auAq3xF4 aFlynwBRa2v:(UIWindow*) aFlynwBRa2v aWVMHJ7nw:(UIBarButtonItem*) aWVMHJ7nw aluH1RhoO:(UIDocument*) aluH1RhoO aHB2Zse:(UIImageView*) aHB2Zse a7h4Q:(UIScreen*) a7h4Q a8zGCvhA:(UIFont*) a8zGCvhA auVIyHkDUQi:(UIMenuItem*) auVIyHkDUQi abi5M:(UIAlertView*) abi5M {
  73. NSLog(@"x0eoOIrJPqFMmBt9KuGlzUkcZwjaHg");
  74. NSLog(@"aM47d6WsyxioXCz2rkZwOQI91lAE0Rg");
  75. NSLog(@"BhFA15caf3idCELG7SD");
  76. NSLog(@"HZ5JLrNPb6tujyvpQ3fsl0TVqE");
  77. NSLog(@"MC0wZ9iRkPO53UAzsarL7HFgD");
  78. NSLog(@"vET4kIQV1isLcjXah3");
  79. NSLog(@"e3aCuhZg6UcIQwR2kDBiLr4");
  80. NSLog(@"yhLY6utJoD3nRdfZO1sH");
  81. NSLog(@"IEoCUs8r49Rpqy02xkA57lKmdvhD3jXbVn1Yct6");
  82. NSLog(@"bkZ18tpKFu3lwUMJOPB9A46E");
  83. NSLog(@"FYz23Zvw5Tgf");
  84. NSLog(@"IDnO5KYWezyEZw");
  85. }
  86. -(void)aQ5CwJ3IGVo:(UIKeyCommand*) aQ5CwJ3IGVo aAEhspCai:(UIActivity*) aAEhspCai aGkQA:(UIMotionEffect*) aGkQA a5uJrw:(UISearchBar*) a5uJrw amaSLzTvK:(UIEvent*) amaSLzTvK aUcm5h6uCO:(UISwitch*) aUcm5h6uCO atbAUVgD:(UIBezierPath*) atbAUVgD aE4bzyft:(UIDocument*) aE4bzyft aNhn4SY:(UIBarButtonItem*) aNhn4SY aGh65y:(UIAlertView*) aGh65y aLFPr5qxjD:(UIMotionEffect*) aLFPr5qxjD auQ5DTWAH4b:(UIEvent*) auQ5DTWAH4b a8wNPLleY:(UIImage*) a8wNPLleY ayPrUdtx:(UISwitch*) ayPrUdtx a6q79:(UIBarButtonItem*) a6q79 acBNDu4:(UIKeyCommand*) acBNDu4 aiU9PgACwoT:(UIMenuItem*) aiU9PgACwoT aOVpX7uISh:(UIControlEvents*) aOVpX7uISh a20estH:(UIAlertView*) a20estH aJm8kFc4:(UICollectionView*) aJm8kFc4 {
  87. NSLog(@"dfiuIoHsYayW1bJG7mU0Djrq2e3VFcXnR5Q");
  88. NSLog(@"ASvk7UfLsFK0bZQrMGndhPoEpi8q");
  89. NSLog(@"TiBI5Xd20FgGqeOQEowfyZULhKnrSakcRJju4");
  90. NSLog(@"gD9oOdp5mXuZ6PqKRQxNlHjG0c");
  91. NSLog(@"JjSRKdpEFOcZTo1aB7WQ");
  92. NSLog(@"037Qhb9D8eas2SL4jUvyktn");
  93. NSLog(@"Pqg1czldDAENG8aThIY4br9yZJ");
  94. NSLog(@"ZklLAHR58DVIPONqKoE7");
  95. NSLog(@"cDxow9g4EGFX5VlZfMIyakRvi7rUASTh");
  96. NSLog(@"HyfJAqksUdhjxpoCnIuGg39rXK1ewM2SbVW");
  97. NSLog(@"3aWcGrSjTQuXAP0YLox5RNVObsf");
  98. NSLog(@"8YeMpjrA69wGbDVfToyLEkHs1xatnNUC");
  99. NSLog(@"pvGJoq9TaN6lVQgFUcWAyKweYM21");
  100. NSLog(@"ZL4PqvNOzaJGVyTfKsci3R2nBx9gDjmhECFkbI1U");
  101. NSLog(@"5nwHvlPoDbgzO8V3c9EWx0ZLBsaiYkJh27u");
  102. NSLog(@"S7fqsNTIFWMlLoxJ15nmzk");
  103. NSLog(@"SeO0T9Kscb");
  104. NSLog(@"TAJn3lB0iwqFsmpfOvWbSKIkxRMXV");
  105. NSLog(@"PRr8ViaUpH");
  106. NSLog(@"0kdm9uOfVLMJqsRvWITN7ErnA");
  107. }
  108. -(void)aeSig:(UIColor*) aeSig apI9h6Bvyel:(UIBarButtonItem*) apI9h6Bvyel aHmLjd4ObAi:(UIColor*) aHmLjd4ObAi aBiC3:(UIViewController*) aBiC3 aLH30Yj:(UIMotionEffect*) aLH30Yj aMjTfAREc:(UIControl*) aMjTfAREc {
  109. NSLog(@"0lfjZpqxTYS8FiJrz1nRWNaGkOCcXDB4voUmQ");
  110. NSLog(@"maeCtxXpyiowkWv93BHA4nhlSqVzZI5ruc1");
  111. NSLog(@"oXtVHvbWpFAE87OxiLgh4");
  112. NSLog(@"gSuV9EiZtHrkmPAbo0FwDvlYI38JGyK4dTzp");
  113. NSLog(@"uFKGJPwQ3kUTYt");
  114. NSLog(@"NIn1JwBlVQZrP4Fo6UWHC0bkEquesS");
  115. NSLog(@"w5DU1WsovOkHA8XSI");
  116. NSLog(@"DqP645IyBVZoC");
  117. NSLog(@"73UwRlv0aZkhenurxmE51PIHiJN2MXO6");
  118. NSLog(@"bkpzCGNKMj6L257a4HFSmxtW8DIRPEsuOyXhvd");
  119. NSLog(@"HxZ0N2YnB4elO1wGTIVgo3hEMasdcQipmFvCjX5");
  120. NSLog(@"sDigOXWuFx4RBMeESAqG9o3cmVrLy5C2kJd");
  121. NSLog(@"zL5yQZip92TYuhSO");
  122. NSLog(@"1inBzSolQW8UcR6");
  123. }
  124. -(void)aX1z5ENeqC2:(UIEdgeInsets*) aX1z5ENeqC2 ayUS7qr5Z:(UIFontWeight*) ayUS7qr5Z a9MNW1bTtkm:(UIDocument*) a9MNW1bTtkm aPzpQLaI7:(UIApplication*) aPzpQLaI7 ahQqpR1x:(UILabel*) ahQqpR1x {
  125. NSLog(@"untHIrTRDeFjBOiaVJG0WfKm5XsyqLh");
  126. NSLog(@"8dBYwGzL0FMUAmJ");
  127. NSLog(@"7ZKgBFO1YMepz6UTDsPtR32Vn");
  128. NSLog(@"pZ5DMe2vyqjQ1V68TI73gcPnU4dhs9E");
  129. NSLog(@"45zOF6fpvE0lhjcmQBNu2y9VHgLMtenDd");
  130. NSLog(@"u5rfXAZgmTMeoypK3W0SdCk4DL");
  131. NSLog(@"v4dxNGnu0IspfkiMO29KwCDWj5eSybgLmaT");
  132. NSLog(@"YTWCfKiueBOqr5kdm4M8bI2ozPQ9gp");
  133. NSLog(@"8O0LCEshU1BlKqANGwuxDcJRH9edbgz7rP");
  134. NSLog(@"FLRQ5UAfCzWIOo9lsuVtbXrP");
  135. NSLog(@"qEwLid7TczVPBp9yrvOlu634bN2nj8tmW");
  136. NSLog(@"oHtBnFjZTW9wUaQYXkRLyvKrJC6DS0e");
  137. NSLog(@"9YKEsSOwgviyBJbNkP7lF3VzjcWDTaRLr");
  138. NSLog(@"lIXEJ5eMbDrLTv4Nz8jox9SRqdGsOPmWAk13CntZ");
  139. NSLog(@"kuqsImnGRl4X");
  140. NSLog(@"ztg1XSMJ2F");
  141. NSLog(@"cm0HCRQIU1");
  142. }
  143. -(void)a43oQD:(UITableView*) a43oQD aYBvl3jbAOa:(UIBezierPath*) aYBvl3jbAOa aCpTS:(UIEdgeInsets*) aCpTS axRUTZg:(UIEvent*) axRUTZg agDoEk9TKFX:(UIAlertView*) agDoEk9TKFX aVFnEk:(UISwitch*) aVFnEk abLkWgVp:(UIMotionEffect*) abLkWgVp aSx2KvuGPY:(UICollectionView*) aSx2KvuGPY aMIqlXpahQ:(UIControlEvents*) aMIqlXpahQ ax8B2:(UIMotionEffect*) ax8B2 aGm3He7Cs56:(UICollectionView*) aGm3He7Cs56 aQeP2B:(UIBarButtonItem*) aQeP2B aenoNUH6C:(UIActivity*) aenoNUH6C {
  144. NSLog(@"J6Zq9eainzBD8OpAjUQCEkx2bMYod0Lu7yT3hcmP");
  145. NSLog(@"vCB5cjTqoZL3EJl72H16t9nbzgmuYN");
  146. NSLog(@"T90rmQtDvYR5FVSkdKg61Lh7nC8saxo");
  147. NSLog(@"3jFWBJq9dxXt1K");
  148. NSLog(@"VTxKykhFc6YX");
  149. NSLog(@"oE7Kkja6YBbeycwI2p9V3SqLrH1");
  150. NSLog(@"I4u5iGF1N0sylCAXbV");
  151. NSLog(@"I7ecUmPVon3XdwrqTifD8ARBxj5OsgHuyvZ");
  152. NSLog(@"jhHCK3fpVJkz");
  153. NSLog(@"hGdKYuCgofx");
  154. }
  155. -(void)a9jkyw:(UIVisualEffectView*) a9jkyw a7txup1H:(UIKeyCommand*) a7txup1H aWh78vn:(UIMenuItem*) aWh78vn alEGXOVJ:(UISearchBar*) alEGXOVJ axRIt:(UIBarButtonItem*) axRIt {
  156. NSLog(@"9DsCgFwX8tG6BPhE4rNMa");
  157. NSLog(@"a4SWXyhcwf609BACJuMG8HFYxnpEU3iq71dzR");
  158. NSLog(@"zbug3dVY1qj24AnwiMQGCoItx9LmvasDe60l");
  159. NSLog(@"fSpcGKTkDVHul7qdFLO8");
  160. NSLog(@"pQZvnz83xaYKiBr5T2uqh0OAbclg7E");
  161. NSLog(@"3ExeC9JP5ouKTSs1ziO7MyNdq");
  162. NSLog(@"jvi3LkOsyRZEVKwneuqUAaYzf8CHQl0");
  163. NSLog(@"byejSRukdaPBZTp7IKwiLr");
  164. NSLog(@"Ytg1bzWfAym284qV6hXNJoMQ");
  165. NSLog(@"dAUbS9HFPEQmTOxVov2Ilskr6X3awyJq");
  166. NSLog(@"RDQbXiP7EAKwFovuC");
  167. NSLog(@"w43tAhTQeIGuCq");
  168. NSLog(@"uAWjNDrOehBKwvi6bdQRy4kmZULH");
  169. NSLog(@"WusSTh1nFKNJprqeY");
  170. NSLog(@"QzeG6RWHdLiYrAxCVj5gswaPNFkuMhU8tI07byvo");
  171. NSLog(@"YSayc1pFmulWIjkM3hwqXZONR8VT2e");
  172. NSLog(@"UgB5rbYqoTxnNI");
  173. }
  174. @end