Thursday, 22 August 2013

Fitting image to UAModalPanel

Fitting image to UAModalPanel

I'm currently using UAModalPanel and I just want show pictures with this
component. So I did the following:
#import <UIKit/UIKit.h>
#import "UAModalPanel.h"
@interface LolcatPanel : UAModalPanel
- (void)showLolcat;
@end
#import "LolcatPanel.h"
@implementation LolcatPanel
- (void)showLolcat
{
int pic = (arc4random() % 10) + 1;
NSString *intString = [NSString stringWithFormat:@"%d", pic];
NSMutableString *picture = [[NSMutableString alloc]
initWithString:intString];
[picture appendString:@".jpg"];
NSLog(@"Loading image %@", picture);
NSString* imageName = [[NSBundle mainBundle] pathForResource:intString
ofType:@"jpg"];
UIImage *testImage = [UIImage imageWithContentsOfFile:imageName];
if (testImage == nil) {
NSLog(@"FAILED");
}
UIImageView *imgView = [[UIImageView alloc]
initWithFrame:CGRectMake(0, 0, self.bounds.size.width,
self.bounds.size.height)];
imgView.image = testImage;
imgView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:imgView];
}
@end
I want to show pictures fitting in the UAModelPanel, but ATM the results
are not really good.

No comments:

Post a Comment