redribben icon

weird image

redribben | PRO | 01/04/15 12:27:47 AM UTC | 0 ⭐ | 437 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    [self beginGeneratingDeviceOrientationNotifications];
}
 
- (void)background {
    
    UIImage *imageA = [UIImage imageNamed:@"123.png"];
    CGSize imageSize = imageA.size;
    CGFloat newWidth = (([[ UIScreen mainScreen ] bounds].size.height) / imageSize.height) * imageSize.width;
    
    UIGraphicsBeginImageContext(self.view.frame.size);
    [imageA drawInRect:CGRectMake(0, 0, newWidth, [[ UIScreen mainScreen ] bounds].size.height)];
    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    self.backgroundView.backgroundColor = [UIColor colorWithPatternImage:resizedImage];
}
 
- (void)beginGeneratingDeviceOrientationNotifications{
    NSLog(@"it started");
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(deviceOrientationDidChangeNotification:)
     name:UIDeviceOrientationDidChangeNotification
     object:nil];
}
 
- (void)deviceOrientationDidChangeNotification:(NSNotification*)note {
    [self background];
    NSLog(@"it changed");
}
 
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

Comments