Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the example #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RGPaperLayout/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
Expand Down Expand Up @@ -89,6 +89,7 @@
</cells>
<connections>
<outlet property="dataSource" destination="vXZ-lx-hvc" id="Nhw-sW-FtM"/>
<outlet property="delegate" destination="vXZ-lx-hvc" id="enX-Ys-TKR"/>
</connections>
</collectionView>
</subviews>
Expand Down
53 changes: 38 additions & 15 deletions RGPaperLayout/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
#import "ViewController.h"
#import "RGCollectionViewCell.h"

@interface ViewController ()
@interface ViewController () <UICollectionViewDelegate>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property NSMutableArray *listOfData;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIImageView *mainImageView;


@end

Expand All @@ -23,31 +27,45 @@ - (void)viewDidLoad {
// Do any additional setup after loading the view, typically from a nib.
self.listOfData = [@[@"climb",@"ice",@"lake",@"shark",@"whale",@"climb",@"ice",@"lake",@"shark",@"whale",@"climb",@"ice",@"lake",@"shark",@"whale"]mutableCopy];

[self setupEffectImage:[UIImage imageNamed:@"climb"]];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Blur Effect Helper Method

- (void)setupEffectImage:(UIImage *)effectImage {
//---> setting up the look of the collection View + the main View
UIVisualEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];

UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:effect];
effectView.frame = self.collectionView.bounds;
UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.collectionView.bounds];
imageView.image = [UIImage imageNamed:@"ice"];

self.imageView = [[UIImageView alloc]initWithFrame:self.collectionView.bounds];
self.imageView.image = effectImage;

UIView *viewFrame = [[UIView alloc]initWithFrame:self.collectionView.bounds];
[viewFrame addSubview:imageView];
[viewFrame addSubview:self.imageView];
[viewFrame addSubview:effectView];

self.collectionView.backgroundView = viewFrame;


UIVisualEffectView *mainEffectView = [[UIVisualEffectView alloc]initWithEffect:effect];
mainEffectView.frame = self.view.bounds;
UIImageView *mainImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
mainImageView.image = [UIImage imageNamed:@"ice"];
UIView *mainViewFrame = [[UIView alloc]initWithFrame:self.view.bounds];
[mainViewFrame addSubview:mainImageView];

self.mainImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
self.mainImageView.image = effectImage;

UIView *mainViewFrame = [[UIView alloc] initWithFrame:self.view.bounds];
[mainViewFrame addSubview:self.mainImageView];
[mainViewFrame addSubview:mainEffectView];

[self.view insertSubview:mainViewFrame belowSubview:self.collectionView];

}

#pragma mark - UICollectionViewDataSource

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
Expand All @@ -70,17 +88,22 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self selectedItemAtIndexPath:indexPath];
}

- (void)selectedItemAtIndexPath:(NSIndexPath *)indexPath {
NSString *nameOfImage = self.listOfData[indexPath.section];
self.imageView.image = [UIImage imageNamed:nameOfImage];
self.mainImageView.image = [UIImage imageNamed:nameOfImage];
}

- (void)configureCell:(RGCollectionViewCell *)cell
forItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *nameOfImage = self.listOfData[indexPath.section];
cell.imageView.image = [UIImage imageNamed:nameOfImage];
cell.label.text = nameOfImage;

}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end