UI in storyboard with zoom functionality - RITAccess/accessmath GitHub Wiki
UIScrollView
- Contains a zoomScale Property that allows the scrollview to zoom both with the tap to zoom functionality as well as the pinchToZoom functionality.
- Allows for scrolling in the area and zooms in on content beneath the scrollView, but disables any scrolling that occurs beneath the view.
Constraints: ScrollView needs elements used like images text, etc. to be embedded into the view itself Makes the TextView more difficult to work with depending on what layer the ScrollView is(i.e the ScrollView is on top of the TextView or Vice versa) Having a universal zoom would take awhile to ensure all controllers that have a scrollView have the same amount of zoom specified by the setting
Example of setting the zoomScale for the scrollView:*
- (void)viewDidLoad {
[super viewDidLoad];
self.scrollView.minimumZoomScale=0.5;
self.scrollView.maximumZoomScale=6.0;
self.scrollView.contentSize=CGSizeMake(1280, 960);
self.scrollView.delegate=self;
}
UITextView
Allows for zooming both programmatically as well as with the pinch gesture and the tap gesture When adding zoom using pinch to zoom programmatically without adding pinch gesture to the TextView, the text font increases in size instead of increasing the general zoom of the area.
Example for the programmatic zoom on a TexView:
//(this is placed in viewDidLoad)
UIPinchGestureRecognizer *gestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(changeFontSize:)];
[_text addGestureRecognizer:gestureRecognizer];
- (void)changeFontSize:(UIPinchGestureRecognizer *)gestureRecognizer {
UITextView *textView = (UITextView *)gestureRecognizer.view;
float yourFontSize = gestureRecognizer.scale * 12;
textView.font = [UIFont systemFontOfSize:yourFontSize];
}
Constraints:
- The zoom area for the textView would be limited to the textView itself and no other elements on the view Controller
- Depending on how much the textView is zoomed in on, it would be more of a task to side scroll if the size is significant enough in comparison to the overall size of the textView area.
- Some cases, such as manually coding the zoom functionality is more of a workaround and increases font size rather than actual zooming using the gestures
UIImageView
Zooming for image is done with the pinch gesture or the tap gesture being added to the UiImageView Uses standard zooming for each with the constraints allotted
Example of pinchToZoom on a UIImageView:
http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer {
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
recognizer.scale = 1;
}
Constraints:
- Does not allow for editable text within the UIView
- Text is static if used for the specified view, and a new image of the proper format would have to be loaded into its place to replace previous image
UIWebView https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/
Gets properties from the ScrollView which allows similar functionality for zooming as the scrollView has
Constraints:
- Information coming from the WebView would need to be loaded from specified url
- Requires the iPad to have internet access in order to load information
- Other constraints are similar to UIScrollView. See ScrollView constraints.
Custom Views and other Views depend on the layering of information and element put on top of the View Controller; see link below: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html
Current iOS Version for specified view: 8.3