This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{ | |
var collectionImage: UIImage? | |
var photoArray: [String] = ["AntMan", "BlackPanther", "BlackWidow", "CaptainAmerican","CaptainMarvel", "Drax", "DrStranger","Gamora", "Hawkeye","Hulk","IronMan","Loki","Mantis","NickFury","Okoye","Pepper","Rocket","ScarletWitch","Thor","Valkyrie", "WinterSoldier", "Wong","Groot","Wasp"] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewCollectionViewCell: UICollectionViewCell { | |
var imageView: UIImageView! | |
override init(frame: CGRect) { | |
super.init(frame: frame) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class PhotoScrollViewViewController: UIViewController, UIScrollViewDelegate{ | |
@IBOutlet weak var myScrollView: UIScrollView! | |
@IBOutlet weak var myImageView: UIImageView! | |
var scrollViewImage: UIImage? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
private let reuseIdentifier = "Cell" | |
class CollectionViewController: UICollectionViewController{ | |
var collectionImage: UIImage? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
private let reuseIdentifier = "Cell" | |
class CollectionViewController: UICollectionViewController{ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
let imageWidth = headScrollView.frame.width | |
//contentSize 滾動區域的大小;CGSize 指定區域大小 | |
headScrollView.contentSize = CGSize(width: imageWidth*14, height: headScrollView.frame.height) | |
bodyScrollView.contentSize = CGSize(width: imageWidth*14, height: bodyScrollView.frame.height) | |
footScrollView.contentSize = CGSize(width: imageWidth*14, height: footScrollView.frame.height) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Timer.scheduledTimer(withTimeInterval: 3, repeats:true) { (_) in | |
var offsetX = self.headScrollView.contentOffset.x + self.headScrollView.frame.width | |
if offsetX == self.headScrollView.contentSize.width { | |
offsetX = 0 | |
} | |
self.headScrollView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: true) | |
} | |
Timer.scheduledTimer(withTimeInterval: 4, repeats: true) { (_) in | |
var offsetX = self.bodyScrollView.contentOffset.x + self.bodyScrollView.frame.width | |
if offsetX == self.bodyScrollView.contentSize.width { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct qna { | |
var question: String | |
var answer: String | |
var choices: [String] = [] | |
} | |
var multiples = [ | |
qna(question: "BMW", answer: "oBMW", choices: ["xBMW", "oBMW"]), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sumis = ["jigsaw1", "jigsaw2", "jigsaw3"] | |
@IBAction func chooseButtonPressed(_ sender: UIButton) { | |
newSumis = self.sumis.shuffled()[0...2] | |
imageView.image = UIImage(named: newSumis[0]) | |
if imageView.image == UIImage(named: "jigsaw1"){ | |
Button0.setBackgroundImage(UIImage(named: "1_0"), for:.normal) | |
Button1.setBackgroundImage(UIImage(named: "1_1"), for:.normal) | |
Button2.setBackgroundImage(UIImage(named: "1_2"), for:.normal) | |
Button3.setBackgroundImage(UIImage(named: "1_3"), for:.normal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GridView: UIView { | |
// Only override draw() if you perform custom drawing. | |
// An empty implementation adversely affects performance during animation. | |
override func draw(_ rect: CGRect) { | |
// Drawing code | |
let path = UIBezierPath() | |
let squareWidth: CGFloat = 110 | |
let lineWidth: CGFloat = 12.5 |