Skip to content

Instantly share code, notes, and snippets.

View akshay1188's full-sized avatar

Akshay Mhatre akshay1188

  • raw engineering
  • San Jose, CA
View GitHub Profile
@akshay1188
akshay1188 / UILabel (BottomAlign)
Created October 17, 2012 09:37
UILabel category to bottom align label texts (Generally when they have different font sizes)
- (CGFloat)topAfterBottomAligningWithLabel:(UILabel *)label{
return (label.frame.origin.y - ((label.frame.origin.y + self.frame.size.height) - (label.frame.origin.y + label.frame.size.height)) + (label.font.descender - self.font.descender));
}
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@akshay1188
akshay1188 / BuiltUITableViewControllerBoilerPlate
Created March 11, 2014 12:26
BuiltUITableViewController boiler plate code
@interface TestBuiltUITableViewController ()
@end
@implementation TestBuiltUITableViewController
- (id)initWithStyle:(UITableViewStyle)style{
self = [super initWithStyle:style];
if (self) {
// Custom initialization