Advertise Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

sdkIQ for iPhone
($4.99)

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Dual Matches
($0.99)

Calcuccino Programmers' Calculator
($2.99)

SDKtoday
(free)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-09-2008, 04:17 AM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Location: Blumenau, Santa Catarina - Brazil
Posts: 6
Default UIImageView Crop

Hi folks, does anyone know how to crop an UIImageView? I have seen this discussion in about a dozen threads but didn't find the answer yet.
I tried some implementations such as:

Initialization

Code:
self.timeBarUIImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kTimeBarSpaceFromLeft, kTimeBarSpaceFromTop, kTimeBarWidth, kTimeBarHeight)];
[self.timeBarUIImageView setImage: [UIImage imageNamed:@"TargetGameTimeBar_100.png"]];
self.timeBarUIImageView.contentMode = UIViewContentModeScaleAspectFill; 
self.timeBarUIImageView.clipsToBounds = YES;
And in a method which is called by a NSTimer I'm trying to clip the UIImageView so as that the image will appear smaller every iteration, using the Code:

Loop

Code:
CGRect frame = [self.timeBarUIImageView frame];
frame.size.width -= kTimeBarDecreasingFactor;
[self.timeBarUIImageView setFrame:frame];

Doing this I can see my UIImageView becoming smaller, but not the way I desire ( I want to clip the image from right to left, soh as that in the last iterations the image displayed would be the most-left portion of the image.
I also tried to play with bounds/center but I didn't get the desired result either (the image became smaller but the final image displayed was the pixels of the center of image (instead of the left-most pixel as I expected)).

I've found resources showing how to use the Low-level API (UIGraphicsGetCurrentContext(), etc) showing the code to resize an UIImage. I also found some interesting link such as Code Sample: Crop an image using the iPhone SDK | Hive05 software products but it didn't work well here.

Any suggestions?
eduardocoelho is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 41,862
Threads: 49,770
Posts: 213,057
Top Poster: BrianSlick (3,139)
Welcome to our newest member, futurevilla216
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0