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
struct PressActions: ViewModifier { | |
var onPress: () -> Void | |
var onRelease: () -> Void | |
func body(content: Content) -> some View { | |
content | |
.simultaneousGesture( | |
DragGesture(minimumDistance: 0) | |
.onChanged({ _ in | |
onPress() |
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
/** | |
Break the provided array to smaller arrays based on the specified maximum | |
number of items on each. | |
- Parameter array: The original array to break in pieces. | |
- Parameter maxItems: The maximum number of elements that each subarray should contain. | |
- Parameter datatype: The datatype of the contained data in the original | |
array. | |
- Returns: A two-dimensional array that contains the subarrays as elements. |
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
/** | |
This is a UIView extension. | |
- Borders are actually UIView objects which are added as subviews to self. | |
- Border views are layed out to self using constraints so they'll work on any change of the view. | |
- Use `BorderSide` enum values to specify the sides of the view you want to add borders to. | |
- For each `BorderSide` value pass along the desired thickness and color of the border as associated values. | |
Example: | |
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
// For more information, visit: | |
// https://gtiapps.com/?p=4482 | |
// It is pressumed that you have added a table view (UITableView) to your view controller, | |
// and that you have set the view controller as the delegate of the tableview (tableView.delegate = self). | |
// Two different approaches are provided: | |
// Approach #1 | |
// Implement the following scroll view delegate method: |