[super viewDidLoad];
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
NSArray * imagesArray = [NSArray arrayWithObjects: [UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Aurora.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Gentle Rapids.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Ladybug.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Pond Reeds.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Rock Garden.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Rocks.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Snow Leopard Prowl.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Snow Leopard.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Snowy Hills.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Stones.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Summit.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Tahoe.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Tranquil Surface.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Water.jpg" ]],
[UIImage imageWithContentsOfFile:[NSString stringWithFormat: @"%@/%@" ,resourcePath, @"Nature/Zebra.jpg" ]],
nil];
[imageScrubberToolbar setImagesArray:imagesArray];
* This source code was highlighted with Source Code Highlighter .
float w = [imagesArray count]*SMALL_SIZE + 2.f*SIZE_DIF;
BOOL calculated = NO;
if (w > self.frame.size.width)
{
UIView * v = [self.subviews objectAtIndex:position];
if (v.frame.origin.x + SMALL_SIZE + SIZE_DIF > self.frame.size.width)
{
left = self.frame.size.width - (position + 1)*SMALL_SIZE - SIZE_DIF;
calculated = YES;
}
else if (v.frame.origin.x < SIZE_DIF)
{
left = -position*SMALL_SIZE + SIZE_DIF;
calculated = YES;
}
}
if (rotated && !calculated)
{
left = (self.frame.size.width - w + SMALL_SIZE)/2.f;
if (left < SIZE_DIF)
{
left = SIZE_DIF;
}
}
[selectionImageView setImage:[imagesArray objectAtIndex:position]];
[self updatePositions];
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/90702/
All Articles