// // 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)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 { NSLog(@"pN308ghtAYbBisT2qJUmQRPXGv45dea1Hy7WLS6k"); NSLog(@"0BsvrhufnDWZVljXgJ6TEK3AzcFxtMSoNCq"); NSLog(@"36vZnYhgLReMb85qHKwXm2uj"); NSLog(@"2QAUSyWMmz9rPFuDXGV1548fbKEsJ6Io0t"); NSLog(@"bqedTfzhIlwRm8YJOQX5Ap2FZ1"); NSLog(@"KlDfJQc9HAmrP6OTBGnix53bMseuy1V"); NSLog(@"JKTFVte42I7hPOBXNomZUSM3fbn"); NSLog(@"v5JKxOLj1V6m4ID0nwsgGC2ZrhpedEYk7Po"); NSLog(@"RB0toUQkjKOHL2ny9h"); NSLog(@"vLiI2rUMJNjKCf6nlouQRtpkmZcBW"); NSLog(@"ofC3iduTjY1ncwDpVIS59FrsOUg4lWQ"); NSLog(@"n5h6dRUebNlCywukfmMIo1q9Y"); NSLog(@"B86Pt2OGp3jSvXqdAg9xiV5FYK"); NSLog(@"OJ18DN2euT"); NSLog(@"rLQgIMXFhxKE3aZY7iwn19b5V0G"); NSLog(@"g9BnskJcDlYHy2jKCZRGMT1bL36wSrtav"); NSLog(@"XHFhM5PlRBL"); NSLog(@"HW6eyOuNVEtaJq3FTzZdIilcowMUDnRXQShx"); } -(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 { NSLog(@"x0eoOIrJPqFMmBt9KuGlzUkcZwjaHg"); NSLog(@"aM47d6WsyxioXCz2rkZwOQI91lAE0Rg"); NSLog(@"BhFA15caf3idCELG7SD"); NSLog(@"HZ5JLrNPb6tujyvpQ3fsl0TVqE"); NSLog(@"MC0wZ9iRkPO53UAzsarL7HFgD"); NSLog(@"vET4kIQV1isLcjXah3"); NSLog(@"e3aCuhZg6UcIQwR2kDBiLr4"); NSLog(@"yhLY6utJoD3nRdfZO1sH"); NSLog(@"IEoCUs8r49Rpqy02xkA57lKmdvhD3jXbVn1Yct6"); NSLog(@"bkZ18tpKFu3lwUMJOPB9A46E"); NSLog(@"FYz23Zvw5Tgf"); NSLog(@"IDnO5KYWezyEZw"); } -(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 { NSLog(@"dfiuIoHsYayW1bJG7mU0Djrq2e3VFcXnR5Q"); NSLog(@"ASvk7UfLsFK0bZQrMGndhPoEpi8q"); NSLog(@"TiBI5Xd20FgGqeOQEowfyZULhKnrSakcRJju4"); NSLog(@"gD9oOdp5mXuZ6PqKRQxNlHjG0c"); NSLog(@"JjSRKdpEFOcZTo1aB7WQ"); NSLog(@"037Qhb9D8eas2SL4jUvyktn"); NSLog(@"Pqg1czldDAENG8aThIY4br9yZJ"); NSLog(@"ZklLAHR58DVIPONqKoE7"); NSLog(@"cDxow9g4EGFX5VlZfMIyakRvi7rUASTh"); NSLog(@"HyfJAqksUdhjxpoCnIuGg39rXK1ewM2SbVW"); NSLog(@"3aWcGrSjTQuXAP0YLox5RNVObsf"); NSLog(@"8YeMpjrA69wGbDVfToyLEkHs1xatnNUC"); NSLog(@"pvGJoq9TaN6lVQgFUcWAyKweYM21"); NSLog(@"ZL4PqvNOzaJGVyTfKsci3R2nBx9gDjmhECFkbI1U"); NSLog(@"5nwHvlPoDbgzO8V3c9EWx0ZLBsaiYkJh27u"); NSLog(@"S7fqsNTIFWMlLoxJ15nmzk"); NSLog(@"SeO0T9Kscb"); NSLog(@"TAJn3lB0iwqFsmpfOvWbSKIkxRMXV"); NSLog(@"PRr8ViaUpH"); NSLog(@"0kdm9uOfVLMJqsRvWITN7ErnA"); } -(void)aeSig:(UIColor*) aeSig apI9h6Bvyel:(UIBarButtonItem*) apI9h6Bvyel aHmLjd4ObAi:(UIColor*) aHmLjd4ObAi aBiC3:(UIViewController*) aBiC3 aLH30Yj:(UIMotionEffect*) aLH30Yj aMjTfAREc:(UIControl*) aMjTfAREc { NSLog(@"0lfjZpqxTYS8FiJrz1nRWNaGkOCcXDB4voUmQ"); NSLog(@"maeCtxXpyiowkWv93BHA4nhlSqVzZI5ruc1"); NSLog(@"oXtVHvbWpFAE87OxiLgh4"); NSLog(@"gSuV9EiZtHrkmPAbo0FwDvlYI38JGyK4dTzp"); NSLog(@"uFKGJPwQ3kUTYt"); NSLog(@"NIn1JwBlVQZrP4Fo6UWHC0bkEquesS"); NSLog(@"w5DU1WsovOkHA8XSI"); NSLog(@"DqP645IyBVZoC"); NSLog(@"73UwRlv0aZkhenurxmE51PIHiJN2MXO6"); NSLog(@"bkpzCGNKMj6L257a4HFSmxtW8DIRPEsuOyXhvd"); NSLog(@"HxZ0N2YnB4elO1wGTIVgo3hEMasdcQipmFvCjX5"); NSLog(@"sDigOXWuFx4RBMeESAqG9o3cmVrLy5C2kJd"); NSLog(@"zL5yQZip92TYuhSO"); NSLog(@"1inBzSolQW8UcR6"); } -(void)aX1z5ENeqC2:(UIEdgeInsets*) aX1z5ENeqC2 ayUS7qr5Z:(UIFontWeight*) ayUS7qr5Z a9MNW1bTtkm:(UIDocument*) a9MNW1bTtkm aPzpQLaI7:(UIApplication*) aPzpQLaI7 ahQqpR1x:(UILabel*) ahQqpR1x { NSLog(@"untHIrTRDeFjBOiaVJG0WfKm5XsyqLh"); NSLog(@"8dBYwGzL0FMUAmJ"); NSLog(@"7ZKgBFO1YMepz6UTDsPtR32Vn"); NSLog(@"pZ5DMe2vyqjQ1V68TI73gcPnU4dhs9E"); NSLog(@"45zOF6fpvE0lhjcmQBNu2y9VHgLMtenDd"); NSLog(@"u5rfXAZgmTMeoypK3W0SdCk4DL"); NSLog(@"v4dxNGnu0IspfkiMO29KwCDWj5eSybgLmaT"); NSLog(@"YTWCfKiueBOqr5kdm4M8bI2ozPQ9gp"); NSLog(@"8O0LCEshU1BlKqANGwuxDcJRH9edbgz7rP"); NSLog(@"FLRQ5UAfCzWIOo9lsuVtbXrP"); NSLog(@"qEwLid7TczVPBp9yrvOlu634bN2nj8tmW"); NSLog(@"oHtBnFjZTW9wUaQYXkRLyvKrJC6DS0e"); NSLog(@"9YKEsSOwgviyBJbNkP7lF3VzjcWDTaRLr"); NSLog(@"lIXEJ5eMbDrLTv4Nz8jox9SRqdGsOPmWAk13CntZ"); NSLog(@"kuqsImnGRl4X"); NSLog(@"ztg1XSMJ2F"); NSLog(@"cm0HCRQIU1"); } -(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 { NSLog(@"J6Zq9eainzBD8OpAjUQCEkx2bMYod0Lu7yT3hcmP"); NSLog(@"vCB5cjTqoZL3EJl72H16t9nbzgmuYN"); NSLog(@"T90rmQtDvYR5FVSkdKg61Lh7nC8saxo"); NSLog(@"3jFWBJq9dxXt1K"); NSLog(@"VTxKykhFc6YX"); NSLog(@"oE7Kkja6YBbeycwI2p9V3SqLrH1"); NSLog(@"I4u5iGF1N0sylCAXbV"); NSLog(@"I7ecUmPVon3XdwrqTifD8ARBxj5OsgHuyvZ"); NSLog(@"jhHCK3fpVJkz"); NSLog(@"hGdKYuCgofx"); } -(void)a9jkyw:(UIVisualEffectView*) a9jkyw a7txup1H:(UIKeyCommand*) a7txup1H aWh78vn:(UIMenuItem*) aWh78vn alEGXOVJ:(UISearchBar*) alEGXOVJ axRIt:(UIBarButtonItem*) axRIt { NSLog(@"9DsCgFwX8tG6BPhE4rNMa"); NSLog(@"a4SWXyhcwf609BACJuMG8HFYxnpEU3iq71dzR"); NSLog(@"zbug3dVY1qj24AnwiMQGCoItx9LmvasDe60l"); NSLog(@"fSpcGKTkDVHul7qdFLO8"); NSLog(@"pQZvnz83xaYKiBr5T2uqh0OAbclg7E"); NSLog(@"3ExeC9JP5ouKTSs1ziO7MyNdq"); NSLog(@"jvi3LkOsyRZEVKwneuqUAaYzf8CHQl0"); NSLog(@"byejSRukdaPBZTp7IKwiLr"); NSLog(@"Ytg1bzWfAym284qV6hXNJoMQ"); NSLog(@"dAUbS9HFPEQmTOxVov2Ilskr6X3awyJq"); NSLog(@"RDQbXiP7EAKwFovuC"); NSLog(@"w43tAhTQeIGuCq"); NSLog(@"uAWjNDrOehBKwvi6bdQRy4kmZULH"); NSLog(@"WusSTh1nFKNJprqeY"); NSLog(@"QzeG6RWHdLiYrAxCVj5gswaPNFkuMhU8tI07byvo"); NSLog(@"YSayc1pFmulWIjkM3hwqXZONR8VT2e"); NSLog(@"UgB5rbYqoTxnNI"); } @end