UIImage *image = [UIImage imageWithContentsOfFile:imgPath];
[but setImage:image forState:state];
NSString *str = but.currentTitle;
CGSize size1 = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];//[str sizeWithFont:[UIFont systemFontOfSize:18] constrainedToSize:CGSizeMake(MAXFLOAT, but.titleLabel.frame.size.height)];
but.titleEdgeInsets =UIEdgeInsetsMake(0.5*image.size.height, -0.5*image.size.width, -0.5*image.size.height, 0.5*image.size.width);
but.imageEdgeInsets =UIEdgeInsetsMake(-0.5*size1.height, 0.5*size1.width, 0.5*size1.height, -0.5*size1.width);