Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
foss-2024-1-final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
사랑 김
foss-2024-1-final
Commits
87499336
Commit
87499336
authored
Jun 23, 2024
by
사랑 김
Browse files
Options
Downloads
Patches
Plain Diff
Upload ViewController.swift
parent
b8e01ace
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Multi-threading_Practice/ViewController.swift
+91
-0
91 additions, 0 deletions
Multi-threading_Practice/ViewController.swift
with
91 additions
and
0 deletions
Multi-threading_Practice/ViewController.swift
0 → 100644
+
91
−
0
View file @
87499336
//
// ViewController1.swift
// FOSS_PR
//
// Created by 김사랑 on 2024/06/23.
//
import
UIKit
class
ViewController
:
UIViewController
{
var
collectionView
:
UICollectionView
!
var
images
:
[
UIImage
]
=
[]
var
originalImages
:
[
UIImage
]
=
[]
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
setupCollectionView
()
setupButtons
()
}
func
setupCollectionView
()
{
let
layout
=
UICollectionViewFlowLayout
()
layout
.
itemSize
=
CGSize
(
width
:
view
.
frame
.
width
-
20
,
height
:
300
)
layout
.
scrollDirection
=
.
vertical
collectionView
=
UICollectionView
(
frame
:
view
.
bounds
,
collectionViewLayout
:
layout
)
collectionView
.
dataSource
=
self
collectionView
.
register
(
UICollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"cell"
)
collectionView
.
backgroundColor
=
.
white
view
.
addSubview
(
collectionView
)
}
func
setupButtons
()
{
let
downloadButton
=
createButton
(
withTitle
:
"이미지 불러오기"
,
action
:
#selector
(
downloadAndProcessImages
))
downloadButton
.
center
=
CGPoint
(
x
:
self
.
view
.
center
.
x
,
y
:
self
.
view
.
frame
.
height
-
130
)
let
filterButton
=
createButton
(
withTitle
:
"흑백 필터 적용하기"
,
action
:
#selector
(
applyFilterToImages
))
filterButton
.
center
=
CGPoint
(
x
:
self
.
view
.
center
.
x
,
y
:
self
.
view
.
frame
.
height
-
90
)
let
resetButton
=
createButton
(
withTitle
:
"되돌리기"
,
action
:
#selector
(
resetImages
))
resetButton
.
center
=
CGPoint
(
x
:
self
.
view
.
center
.
x
,
y
:
self
.
view
.
frame
.
height
-
50
)
view
.
addSubview
(
downloadButton
)
view
.
addSubview
(
filterButton
)
view
.
addSubview
(
resetButton
)
}
func
createButton
(
withTitle
title
:
String
,
action
:
Selector
)
->
UIButton
{
let
button
=
UIButton
(
type
:
.
system
)
button
.
setTitle
(
title
,
for
:
.
normal
)
button
.
backgroundColor
=
.
lightGray
button
.
layer
.
cornerRadius
=
10
button
.
layer
.
masksToBounds
=
true
button
.
titleLabel
?
.
font
=
UIFont
.
systemFont
(
ofSize
:
18
,
weight
:
.
regular
)
button
.
setTitleColor
(
.
black
,
for
:
.
normal
)
button
.
backgroundColor
=
.
init
(
red
:
0.89
,
green
:
0
,
blue
:
1
,
alpha
:
0.5
)
button
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
170
,
height
:
30
)
button
.
addTarget
(
self
,
action
:
action
,
for
:
.
touchUpInside
)
return
button
}
@objc
func
downloadAndProcessImages
()
{
loadImagesUsingOperationQueue
()
}
@objc
func
applyFilterToImages
()
{
applyFilterUsingOperationQueue
()
}
@objc
func
resetImages
()
{
resetImagesUsingOperationQueue
()
}
}
extension
ViewController
:
UICollectionViewDataSource
{
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
return
images
.
count
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"cell"
,
for
:
indexPath
)
for
view
in
cell
.
contentView
.
subviews
{
view
.
removeFromSuperview
()
}
let
imageView
=
UIImageView
(
image
:
images
[
indexPath
.
item
])
imageView
.
frame
=
cell
.
contentView
.
frame
cell
.
contentView
.
addSubview
(
imageView
)
return
cell
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment