UIImageView Scaling Explained Visually

I’ve seen a lot of confusion as to what some of the popular scaling modes actually do for a an image in a UIImageView so here is a visual explanation for some of the most popular layout modes.

 

UIImageView content mode

iPhone 5 SIM card in Samsung Galaxy S3

I picked up my iPhone 5 today and went to Zagg to get an invisible shield put on it. They only had the front shield so I decided not go go that route. I’m going to wait until a full shield comes in and in the mean time I decided to use an extra Galaxy S3 we had at the office (for a couple of days). I went to put the micro SIM from the iPhone 5 into the Micro sim bay for the Galaxy S3 but the iPhone 5 SIM is smaller than your standard micro SIM. The following is what I did to get it to fit anyway.

Basic Android Device Resolutions

Lately at work I’ve been dealing with doing apps for multiple Android devices. I put together a simple image for my findings. Note that the orientations for the Blackberry devices aren’t exact, but the sizes are (click image for full size version)

Basic Android Device Resolutions

A list of the devices mentioned here are:

UIImageView Mode Aspect Fit vs Aspect Fill

At work this last week someone asked what the difference is between a couple of different View Modes for a UIImageView. The two most confusing were Aspect Fit and Aspect Fill. I explained the difference using the whiteboard and decided to take a snapshot of the drawing I used to illustrate the differences.

The dotted red line is the physical boundary of the UIImageView it’s self.

php Truncate String to Nearest Space

Recently at work we needed to truncate a string in php. We found some truncate functions online, but we needed to have a bit more zest so I wrote one.

{syntaxhighlighter brush: php;fontsize: 100; first-line: 1; }function truncateString($str, $chars, $to_space, $replacement=”…”) {
if($chars > strlen($str)) return $str;

$str = substr($str, 0, $chars);

$space_pos = strrpos($str, ” “);
if($to_space && $space_pos >= 0) {
$str = substr($str, 0, strrpos($str, ” “));
}

return($str . $replacement);
}{/syntaxhighlighter}

Custom Fonts For IOS 5

I posted an answer on StackOverFlow recently that I think will be helpful for the the rest of you IOS developers. It’s regarding how to place custom fonts on your labels and textfields in IOS 5.

Enable a Cross-Domain Policy For Files Using .htaccess

Here is a one liner for your .htaccess that will enable scripts in that same folder to be used across domains.

{syntaxhighlighter brush: bash;gutter: false; light: true; fontsize: 100; first-line: 1; }Header add Access-Control-Allow-Origin “*”{/syntaxhighlighter}

Smarter Switch Statements

Recently, a coworker showed me a development script from Apple and we both took an interest in how the web developers used switch statements for the script he had found.

print_r For Actionscript3

I’ve always wanted a print_r function for AS3 that worked like the one in PHP so I finally decided to write my own. As always, please comment back with things that don’t match up with the original print_r and I’ll update.