Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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];
- }
Advertisement
Add Comment
Please, Sign In to add comment