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 Foundation | |
var array = [1,2,1,3,5] | |
func arrayCalculation(_ array: [Int]) -> Int { | |
var dictionary: [Int:Int] = [:] | |
var sortedArray: [Int] = [] | |
// With this portion of the code, I'm iterating over the array and adding the dictionary items to an array |
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
VStack { | |
TabView { | |
//Add Group {} here for vertical method. be sure to add .rotationEffect(Angle(degrees: -90)) at the end of the Group closure | |
ForEach(data) { item in | |
CustomCell(data: item) | |
} | |
} | |
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic)) | |
// Add .rotationEffect(Angle(degrees: 90)) as well for vertical implementation | |
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
// | |
// | |
//Here is the programmatic setup for the CollectionView | |
// | |
// | |
let collectionView: UICollectionView = { | |
let layout = UICollectionViewFlowLayout() | |
layout.scrollDirection = .horizontal //Change this to vertical | |
layout.minimumLineSpacing = 8 //Spacing here is not necessary, but adds a better inset for horizontal scrolling. Gives you a tiny peek of the background. Probably not great for vertical |
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
// The issue I'm running into is that I'm adding D6DiceViews to an array and then | |
// attempting to randomly change the number on each die | |
//Here is the struct for the D6DiceView, it contains the function for the random roll (this is the full current view) | |
struct D6DiceView: View { | |
@Binding var rolledValue: String | |
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
//In your view, declare a UIViewRepresentable as a UIButton type as seen below. | |
//This is important as you cannot do it as a UIBarButtonItem (at least as I've found in Xcode 12 beta 2). | |
struct MenuButtonView: UIViewRepresentable { | |
typealias UIViewType = UIButton | |
let saveAction = UIAction(title: "") { action in } | |
let saveMenu = UIMenu(title: "", children: [ |