Friday, March 25, 2016

Add tint to UIImage

I have been working on a SDK that allows user to customize colors for images. In many cases, I need to add an image to a button with different color at run time. So using just tintColor is not going to work. The following method will mask an image with the color you define.

- (UIImage *)maskWithColor:(UIColor *)color
{
    CGImageRef maskImage = self.CGImage;
    CGFloat width = self.size.width * self.scale;
    CGFloat height = self.size.height * self.scale;
    CGRect bounds = CGRectMake(0,0,width,height);
    
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef bitmapContext = CGBitmapContextCreate(NULL, width, height, 8, 0, colorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast);
    CGContextClipToMask(bitmapContext, bounds, maskImage);
    CGContextSetFillColorWithColor(bitmapContext, color.CGColor);
    CGContextFillRect(bitmapContext, bounds);
    
    CGImageRef cImage = CGBitmapContextCreateImage(bitmapContext);
    UIImage *coloredImage = [UIImage imageWithCGImage:cImage scale:self.scale orientation:self.imageOrientation];
    
    CGContextRelease(bitmapContext);
    CGColorSpaceRelease(colorSpace);
    CGImageRelease(cImage);
    
    return coloredImage;
}

Tuesday, January 20, 2015

Using xcodebuild To Export a .ipa From an Archive

Found this helpful article. 

source: http://www.thecave.com/2014/09/16/using-xcodebuild-to-export-a-ipa-from-an-archive/

Clean project

xcodebuild clean -project $projectname.xcodeproj -configuration Release -alltargets

Create project archive

xcodebuild archive -project $projectname.xcodeproj -scheme $schemename -archivePath $projectname.xcarchive

Create IPA

xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name”

Tuesday, December 23, 2014

Weather for your business?

A beautiful iPhone app before the year end. It is a business analytics app.
In App Store: https://itunes.apple.com/us/app/weathr-lite/id980422041?ls=1&mt=8

Wednesday, October 1, 2014

Directory with extra fun

Employee look up app with fun ideas.


Wednesday, September 24, 2014

VW Interactive Ad Unit

Built the API services for an Ad unit that is personalized for each CBS fantasy football team.
  • Each team plays 10 unique questions each week and earn points. 
  • Leader board for each league. 
  • History for last week's score. 



Tuesday, April 15, 2014

How to install ImageMagick with MAMP

1. Install Homebrew http://brew.sh/
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
2. Install ImageMagick for the PHP version your MAMP is running.
brew search imagick
brew install php55-imagick
After installation, the ImageMagick PHP extension is created in /usr/local/Cellar/php55-imagick/3.1.0RC2/imagick.so
3. Disable the DYLD_LIBRARY_PATH variable in Apache's environmental variables.
vi /Applications/MAMP/Library/bin/envvars
Comment out the following line:
export DYLD_LIBRARY_PATH
4. Update php.ini to include imagick.so
vi /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
Add the following line.
extension="/usr/local/Cellar/php55-imagick/3.1.0RC2/imagick.so";
5. Restart MAMP
6. Check if imagick is included in phpinfo()

Monday, March 3, 2014

A simple copying directory function

function recurseCopy($src, $dst, $excludeFileType=array()) {
    $dir = opendir($src);
    mkdir($dst, 0755, true);
    while(false !== ( $file = readdir($dir)) ) {
        if (( $file != '.' ) && ( $file != '..' )) {
            if ( is_dir($src . '/' . $file) ) {
                $this->recurseCopy($src . '/' . $file, $dst . '/' . $file, $excludeFileType);
            }
            else {
                $filePathInfo = pathinfo($file);
                $ext = '';
                if(!empty($filePathInfo['extension'])){
                    $ext = $filePathInfo['extension'];
                }
                if(empty($ext) || !in_array($ext, $excludeFileType)){
                    copy($src . '/' . $file, $dst . '/' . $file);
                }
            }
        }
    }
    closedir($dir);
}