This file contains 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 { | |
var label:UILabel? = nil | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
setupHardCodeLabel() |
This file contains 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
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view. | |
[self addBottomSheetView]; | |
} | |
- (void)addBottomSheetView { | |
BottomSheetViewController *bottomSheetVc = [BottomSheetViewController new]; | |
[self addChildViewController:bottomSheetVc]; | |
[self.view addSubview:bottomSheetVc.view]; |
This file contains 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
- (void)panGesture:(UIPanGestureRecognizer *)recognizer { | |
// Bottom Sheet 會隨著手勢移動跟著移動 | |
[self moveViewWithGesture:recognizer]; | |
// 當手移開螢幕時,Bottom Sheet 會根據新狀態移動到對應位置 | |
if (recognizer.state != UIGestureRecognizerStateEnded) { | |
return; | |
} | |
// 以動畫效果來漸進畫面的移動 |
This file contains 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
static CGFloat fullViewYPosition = 0; | |
static CGFloat partialViewYPosition = 0; | |
static CGFloat expandedViewYPosition = 0; | |
- (void)setupData { | |
fullViewYPosition = 100; | |
partialViewYPosition = [UIScreen mainScreen].bounds.size.height - 130; | |
expandedViewYPosition = [UIScreen mainScreen].bounds.size.height - 130 - 130; | |
self.lastStatus = expanded; |
This file contains 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
- (void)setupGestureEvent { | |
UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)]; | |
[self.view addGestureRecognizer:gesture]; | |
[self roundViews]; | |
} | |
- (void)roundViews { | |
self.view.layer.cornerRadius = 10; | |
self.view.clipsToBounds = YES; | |
} |
This file contains 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
#!/bin/sh | |
# reference | |
# https://www.twblogs.net/a/5b8c3b1a2b71771883317c2c | |
BUILD_RESULT_PATH=build_output | |
if [ -x nasm ]; then | |
wget "https://www.nasm.us/pub/nasm/releasebuilds/2.14.03rc2/macosx/nasm-2.14.03rc2-macosx.zip" | |
unzip nasm-2.14.03rc2-macosx.zip |
This file contains 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
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DragDrogCollectionViewCell", for: indexPath) as! DragDrogCollectionViewCell | |
let index = indexPath.section * ViewController.columnCount + indexPath.row | |
cell.backgroundColor = UIColor.clear | |
cell.label.text = "" | |
if (index < cellDataList.count) { | |
cell.backgroundColor = UIColor.yellow | |
cell.label.text = String(cellDataList[index]) | |
} |
This file contains 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
func updateDataIndex(from fromIndexPath: IndexPath, to toIndexPath: IndexPath) { | |
let fromPosition = fromIndexPath.item | |
let toPosition = toIndexPath.item | |
let selected = cellDataList[fromPosition] as Int | |
DispatchQueue.main.async {[weak self] in | |
self?.cellDataList.remove(at: fromPosition) | |
var newindex = toPosition | |
if (newindex > self?.cellDataList.count ?? 0) { | |
newindex = self?.cellDataList.count ?? 0 |
This file contains 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 ViewController: UIViewController { | |
func setupCollectionView() { | |
self.collectionView.collectionViewLayout = columnLayout | |
self.collectionView.dataSource = self | |
self.collectionView.dragInteractionEnabled = true | |
self.collectionView.dragDelegate = self | |
self.collectionView.dropDelegate = self | |
} | |
func updateDataIndex(from fromIndexPath: IndexPath, to toIndexPath: IndexPath) { |
This file contains 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
func setupCollectionView() { | |
self.collectionView.collectionViewLayout = columnLayout | |
self.collectionView.dataSource = self | |
self.collectionView.dragDelegate = self | |
self.collectionView.dragInteractionEnabled = true | |
} | |
extension ViewController: UICollectionViewDragDelegate { | |
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { | |
let attributedString = String(indexPath.item) |
NewerOlder