I am trying to use a UISwitch in my UINavigationBar. I want a smaller switch than the default, so I am scaling the size down with anonymousSwitch.transform = CGAffineTransformMakeScale(0.55, 0.55); When I do this, the switch shrinks, but I cannot figure out how to align it vertically with the other elements in my UINavigationBar.
Here is what it looks like currently:
Ideally, the UISwitch would be spaced away from the 175 UILabel as much as the X UIButton is spaced from the 175 UILabel, and the UISwitch would be in a straight line with the rest of the elements in the UINavigationBar. I tried doing switch.center = CGPointMake(switch.center.x, shareButton.center.y), but this did not affect the placement of the UISwitch at all.
Is there any way for me to position the switch like I want?
I had the same problem.
I tried to solve it and came up with this solution.
I don't think it's a perfect solution and might not work on every iOS-Version.
First you need to subclass UISwitch like this:
#interface UICustomSwitch : UISwitch
#property (assign, nonatomic) CGFloat scale;
#end
#implementation UICustomSwitch
- (void)setFrame:(CGRect)frame {
CGFloat superview_height = self.superview.frame.size.height;
frame.origin.y = (superview_height - frame.size.height * _scale) / 2;
[super setFrame:frame];
}
#end
The second thing to do is to create and setup your UICustomSwitch like that:
UICustomSwitch* switch = [UICustomSwitch new];
switch.transform = CGAffineTransformMakeScale(0.75, 0.75);
switch.scale = 0.75;
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithCustomView:switch];
To create a bigger space between the 175 and the switch you could just add another UIBarButtonItem between the 175 and the switch. E.g. a fixed spacer with a specific width.
Like i said, i don't think it's a flawless solution.
In my tests it worked.
Another solution by 0yeoj (but a little bit adjusted -> always centered for every navigationBar height, for toolbars it's the same, just use self.navigationController.toolbar.frame.size.height ):
UIView* switch_container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, self.navigationController.navigationBar.frame.size.height)];
UISwitch* switch = [[UISwitch alloc] initWithFrame:switch_container.bounds];
switch.transform = CGAffineTransformMakeScale(0.75, 0.75);
switch.center = CGPointMake(switch_container.bounds.size.width/2, switch_container.bounds.size.height/2);
[switch addTarget:self action:#selector(action:) forControlEvents:UIControlEventValueChanged];
[switch_container addSubview:switch];
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithCustomView:switch_container];
self.navigationItem.rightBarButtonItem = button;
Have you tried moving switch with another transform method like,
CGAffineTransformMakeTranslation(xValue, yValue);
also you can merge two transform together and give that transform to switch like,
CGAffineTransform scale= CGAffineTransformMakeScale(0.55, 0.55);
CGAffineTransform translate = CGAffineTransformMakeTranslation(0, 10);
anonymousSwitch.transform = CGAffineTransformConcat(scale, translate);
This is the code i tested..
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *xbutton = [UIButton buttonWithType:UIButtonTypeCustom];
xbutton.frame = CGRectMake(0, 6, 35, 35);
xbutton.backgroundColor = [UIColor redColor];
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
UISwitch *switchButton = [[UISwitch alloc] init];
switchButton.frame = CGRectMake(0, 0, 35, 35);
switchButton.transform = CGAffineTransformMakeScale(0.55, 0.55);
switchButton.center = CGPointMake(containerView.frame.size.width/2, containerView.frame.size.height/2);
[containerView addSubview:switchButton];
UIBarButtonItem *additionalButton = [[UIBarButtonItem alloc] initWithCustomView:containerView];
UIBarButtonItem *xBarButton = [[UIBarButtonItem alloc] initWithCustomView:xbutton];
//rearrange it if necessary
NSArray *arrayButton = [NSArray arrayWithObjects: xBarButton, additionalButton, nil];
self.navigationItem.leftBarButtonItems = arrayButton;
}.
hmm... i haven't DOWNGRADED yet to yosemite so i dont have ios8.3 here this code works perfectly for me though..
Related
Currently I'm trying to make 3 buttons in a horizontal group of 3 that have equal spacing
UIStackView * menuButtons = [[UIStackView alloc] initWithFrame:CGRectMake(0, 0, 60, 16)];
menuButtons.axis = UILayoutConstraintAxisHorizontal;
menuButtons.alignment = UIStackViewAlignmentBottom;
menuButtons.spacing = 6;
menuButtons.distribution = UIStackViewDistributionEqualSpacing;
UIButton* btnOne = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
UIButton* btnTwo = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
UIButton* btnThree = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
[menuButtons addArrangedSubview:btnOne];
[menuButtons addArrangedSubview:btnTwo];
[menuButtons addArrangedSubview:btnThree];
ive noticed when I inspect the frame of the button views after adding them to my stackview programatically, they all show different sizes than originally set, when I expect them all to still be 16
ie: btnOne CGSize(17, 16), btnTwo CGSize(23.5, 23,5), btnThree CGSize(21.3, 21.3)
I don't understand why this happens, and I've tried all the distributions but I can't figure this out when I'm not setting the frames on these views anywhere else
Here is an example - based on your code - using auto-layout constraints.
Note that you do NOT need to specify width and height constraints for your UIStackView, as it will expand as needed to fit the arranged subviews.
If you do set a width constraint, you'll end up with (likely) unexpected results, because you've also specified fixed-width spacing of 6.
So, you would want either:
width constraint + UIStackViewDistributionEqualSpacing, or
no width constraint + default distribution + .spacing = 6
Hope this helps...
//
// StackTestViewController.m
//
// Created by Don Mag on 6/24/17.
//
#import "StackTestViewController.h"
#interface StackTestViewController ()
#end
#implementation StackTestViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupMenuButtons];
}
- (void)setupMenuButtons {
// instantiate a UIStackView
UIStackView *menuButtons = [[UIStackView alloc] init];
// horizontal
menuButtons.axis = UILayoutConstraintAxisHorizontal;
// spacing between arranged views
menuButtons.spacing = 6;
// instantiate 3 buttons
UIButton* btnOne = [UIButton new];
UIButton* btnTwo = [UIButton new];
UIButton* btnThree = [UIButton new];
// give 'em background colors so we can see them
btnOne.backgroundColor = [UIColor redColor];
btnTwo.backgroundColor = [UIColor greenColor];
btnThree.backgroundColor = [UIColor blueColor];
// for each button,
// tell it not to use Autoresizing Mask
// set width and height constraints each to 16
for (UIButton *b in #[btnOne, btnTwo, btnThree]) {
[b setTranslatesAutoresizingMaskIntoConstraints:NO];
[b.widthAnchor constraintEqualToConstant:16.0].active = YES;
[b.heightAnchor constraintEqualToConstant:16.0].active = YES;
}
// add them to the Stack View
[menuButtons addArrangedSubview:btnOne];
[menuButtons addArrangedSubview:btnTwo];
[menuButtons addArrangedSubview:btnThree];
// add the Stack View to self view
[self.view addSubview:menuButtons];
// tell Stack View not to use Autoresizing Mask
[menuButtons setTranslatesAutoresizingMaskIntoConstraints:NO];
// set X and Y position for the Stack View (just using 80,80 for this example)
[menuButtons.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:80.0].active = YES;
[menuButtons.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:80.0].active = YES;
}
#end
I am trying to rotate a UITextView in my VC. When I try to rotate it the UITextView resizes its?
Here is my code.
- (void)viewDidLoad {
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
self.title = #"Signature View";
[self.signatureView setLineWidth:2.0];
self.signatureView.foregroundLineColor = [UIColor colorWithRed:0.204 green:0.596 blue:0.859 alpha:1.000];
NSLog(#"contentsize: %.0f, %.0f", self.view.frame.size.width, self.view.frame.size.height); <-- this is (contentsize: 320, 568)
self.howToTextView.frame = CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width);
[self.howToTextView setNeedsDisplay]; <-- to make it redraw
[self.howToTextView setTransform:CGAffineTransformMakeRotation(-90* M_PI/180)];
NSLog(#"contentsize: %.0f, %.0f", self.howToTextView.contentSize.width, self.howToTextView.contentSize.height); <--- turns out to be (contentsize: 103, 138)same as on storyboard design
}
UPDATE(With this code the uitextview is in place and the frame is right, but not the text won't resize to fill up the uitextviews new frame size. Its stuck down in the bottom corner?):
- (void)viewDidLoad {
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
self.title = #"Signature View";
[self.signatureView setLineWidth:2.0];
self.signatureView.foregroundLineColor = [UIColor colorWithRed:0.204 green:0.596 blue:0.859 alpha:1.000];
NSLog(#"contentsize: %.0f, %.0f", self.view.frame.size.width, self.view.frame.size.height);
self.howToTextView = [[UITextView alloc] init];
self.howToTextView.backgroundColor = [UIColor redColor];
self.howToTextView.text = #"this is a good day. i am going to make millions today. Smile while on the phone as it is the best way to increase your business. I hope that you like this app as we have work really hard on it. Please sign your name or decline but if you decline then you understand you lose all coverage.";
[self.view addSubview:self.howToTextView];
[self.howToTextView setTransform:CGAffineTransformMakeRotation(-90* M_PI/180)];
self.howToTextView.frame = CGRectMake(0, 0, 80, self.view.frame.size.height);
[self.howToTextView setNeedsDisplay];
NSLog(#"contentsize: %.0f, %.0f", self.howToTextView.contentSize.width, self.howToTextView.contentSize.height);
}
UPDATE 2: Sticking the textview inside a UIView makes the content size right, but now with this code the uitextview/uiview are in the top right corner of the app, even though I set them both to be 0,0 for x,y? Not sure why that is?
self.howToTextView = [[UITextView alloc] init];
[self.howToTextView setFrame:CGRectMake(0, 0, self.view.frame.size.height-20, 110)];
self.howToTextView.backgroundColor = [UIColor redColor];
self.howToTextView.text = #"this is a good day. i am going to make millions today. Smile while on the phone as it is the best way to increase your business. I hope that you like this app as we have work really hard on it. Please sign your name or decline but if you decline then you understand you lose all coverage.";
UIView *myRotateView = [[UIView alloc] init];
[myRotateView setFrame:CGRectMake(0, 0, self.view.frame.size.height, 120)];
[myRotateView setBackgroundColor:[UIColor greenColor]];
[myRotateView addSubview:self.howToTextView];
myRotateView.transform = CGAffineTransformMakeRotation(-90* M_PI/180);
[[self view] addSubview:myRotateView];
After two days of struggling, I found a workaround:
Create a UIView.
Add your UITextView as a sub view to it.
Get the proper size of UITextView, using sizeThatFits().
Set UITextView frame.
Set UIView frame with 0 heigh and 0 width (it's important!).
Rotate your UIView.
Now if you want to change font size do it like this:
myTextView.font = UIFont.boldSystemFontOfSize(size)
let maxsize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT)
let frame = myTextView.sizeThatFits(maxsize)
myTextView.frame = CGRectMake(0, 0, frame.width, frame.height)
At end rotate the UIView again.
I want to add a Label and an Image in titleView of my NavigationItem. I am adding UILabel and UIImageView to a UIView and setting it as titleView of the navigation Item. Things are being added, but I am not able to calculate the length of label and place image next to it.
My code is :-
// Title Name + Image
UIView *titView = [[UIView alloc] initWithFrame:self.navigationItem.titleView.bounds];
self.navigationItem.titleView = titView;
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(-10, -20, 150, 30)];
title.text = #"Bunny ";
[title setTextColor:[UIColor orangeColor]];
[titView addSubview:title];
float x2 = 30; //+ title.bounds.size.width;
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"return" ]];
img.frame = CGRectMake(x2, -20, img.bounds.size.width, 30);
[titView addSubview:img];
I am looking for some way to calc the width text and set accordingly the width of the label. Right now I have set the width of the label as 150. And secondly, calc the x position to place the image just next to the label.
Tried many ways, but nothing works as expected. How can I achieve this ? Can you he give some guidelines such that regardless of length of text of label, things works as expected and UIView gets placed in the center of navigation item.
Any help is highly appreciated. Thanks.
You can call
[title sizeToFit];
after setting its properties and it will size itself to match the contained string.
Set the imageViews x origin to
CGRectGetMaxX(title.frame) + desiredSpacing;
And it could help to subclass UIView to achieve the final results by overwriting layoutSubviews and placing your views there, since the titleView's frame can be adjusted by the navigationBar...basically like this:
#implementation TitleView{
UILabel *_titleLabel;
UIImageView *_img;
}
- (id)initWithTitle:(NSString *)title andImage:(UIImage *)image
{
self = [super init];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = title;
[_titleLabel setTextColor:[UIColor orangeColor]];
[_titleLabel sizeToFit];
[self addSubview:_titleLabel];
_img = [[UIImageView alloc] initWithImage:image];
[self addSubview:_img];
}
return self;
}
- (void)layoutSubviews{
CGFloat spacingBetweenTextAndImage = 0;
CGFloat width = CGRectGetWidth(_titleLabel.frame)+CGRectGetWidth(_img.frame)+spacingBetweenTextAndImage;
CGFloat x = (CGRectGetWidth(self.bounds)-width)/2;
_titleLabel.frame = CGRectMake(x, (CGRectGetHeight(self.bounds)-CGRectGetHeight(_titleLabel.bounds))/2, CGRectGetWidth(_titleLabel.bounds), CGRectGetHeight(_titleLabel.bounds));
x+=CGRectGetWidth(_titleLabel.bounds)+spacingBetweenTextAndImage;
_img.frame = CGRectMake(x, (CGRectGetHeight(self.bounds)-CGRectGetHeight(_img.bounds))/2, CGRectGetWidth(_img.bounds), CGRectGetHeight(_img.bounds));
}
#end
use in your viewController:
UIView *titleView = [[TitleView alloc] initWithTitle:#"Bunny" andImage:[UIImage imageNamed:#"return" ]];
self.navigationItem.titleView = titleView;
I have a method were I'm creating UIView and it works fine when I call it from IBAction. But when I call the same method again it draws another view on top and I believe it's a memory leak. How do I remove previous UIView before creating another one? Thanks!
- (int)showQuestionMethod:(int)number;
{
UIView *questionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 250)];
questionView.backgroundColor = [[UIColor alloc] initWithRed:0.93 green:0.93
blue:0.93 alpha:1.0];
[self.view addSubview:questionView];
questionView.tag = questionNumber;
UILabel *questionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 0)];
questionLabel.text = question1;
[questionView addSubview:questionLabel];
CGRect frame = questionView.frame;
frame.size.height = questionHeight;
questionView.frame = frame;
questionView.tag = questionNumber;
return currentQuestion;
}
- (IBAction)nextQuestion:(id)sender {
[self showQuestionMethod:questionNumber];
}
Create a property which will let you reference a view:
#property(nonatomic, strong) UIView *questionView;
Then change your method to remove the old view and create a new one:
- (int)showQuestionMethod:(int)number;
{
// Remove the previous view.
[_questionView removeFromSuperview];
// Create a new view.
_questionView= [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 250)];
_questionView.backgroundColor = [[UIColor alloc] initWithRed:0.93 green:0.93
blue:0.93 alpha:1.0];
// Add the view.
[self.view addSubview:_questionView];
_questionView.tag = questionNumber;
UILabel *questionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 0)];
questionLabel.text = question1;
[_questionView addSubview:questionLabel];
CGRect frame = _questionView.frame;
frame.size.height = questionHeight;
_questionView.frame = frame;
_questionView.tag = questionNumber;
return currentQuestion;
}
The simplest way would be to keep a reference to the view you will want to remove (a private property would work nicely). You could add the code at bottom to the top of your controllers .m file:
#interface MyUIViewController ()
#property (nonatomic, strong) UIView* questionView;
#end
Then modify your method as follows:
- (int)showQuestionMethod:(int)number;
{
[self.questionView removeFromSuperview]
self.questionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 250)];
self.questionView.backgroundColor = [[UIColor alloc] initWithRed:0.93 green:0.93
blue:0.93 alpha:1.0];
[self.view addSubview:self.questionView];
self.questionView.tag = questionNumber;
UILabel *questionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 0)];
self.questionLabel.text = question1;
[self.questionView addSubview:questionLabel];
CGRect frame = questionView.frame;
frame.size.height = questionHeight;
self.questionView.frame = frame;
self.questionView.tag = questionNumber;
return currentQuestion;
}
use this before creating new view
[myview removeFromSuperview];
You can either keep a reference to the view by adding #property (strong, nonatomic) UIView *questionView; in your #interface declaration then call [_questionView removeFromSuperview]; to remove it.
Or, better yet, keep that reference to it then have a method to reload the info on it and animate it out/back into view (perhaps by fading out, reloading the data on it, then fading it back in). That way you aren't throwing away / recreating views all the time, and instead you're just reusing the same, already created view.
[self.questionView removeFromSuperview];
before adding the other view, remove this from the superview!
Why not reuse the view?
If you'd rather delete it every time and you don't want to keep a reference to it, you can always set (dirty but simple):
questionView.tag = SOME_CONST;
And then add in the beginning of your method:
[[self.view viewWithTag:SOME_CONST] removeFromSuperview];
I know this question has been answered, but i want to add a precaution that you before removing a UIView or anything else you should FIRST CHECK IF IT IS ALLOCATED. So the removal should be like:
// Make property first
#property (nonatomic, strong) UIView *questionView;
- (int)showQuestionMethod:(int)number;
{
// Check it it is allocated
if(questionView)
{
[questionView removeFromSuperView];
//[questionView release]; // Un-Comment it if NOT using ARC
questionView = nil;
}
// At this point you safe to create a new UIView.
questionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 250)];
questionView.backgroundColor = [[UIColor alloc] initWithRed:0.93 green:0.93
blue:0.93 alpha:1.0];
[self.view addSubview:questionView];
questionView.tag = questionNumber;
UILabel *questionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 0)];
questionLabel.text = question1;
[questionView addSubview:questionLabel];
CGRect frame = questionView.frame;
frame.size.height = questionHeight;
questionView.frame = frame;
questionView.tag = questionNumber;
return currentQuestion;
}
Hope the snippet and comment inside makes sense.
Happy Coding!!!
I have a UIToolBar that is intended to contain sliders for controlling volume and brightness. I use a MPVolumeView slider for the volume, and an ordinary UISlider for the brightness. While the sliders themselves work fine, their vertical positions are mismatched:
How do I get them to be on the same height?
My code:
- (void) createToolbar{
toolBar = [[UIToolbar alloc] init];
toolBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
UISegmentedControl *modeSelector = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:#"Play", #"Rec", nil]];
[modeSelector setSegmentedControlStyle:UISegmentedControlStyleBar];
[modeSelector addTarget:self action:#selector(changePlayMode) forControlEvents:UIControlEventValueChanged];
modeSelector.selectedSegmentIndex = 0;
UIBarButtonItem *modeSelectorAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:modeSelector];
brightnessSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
brightnessSlider.minimumValue = 0;
brightnessSlider.maximumValue = 1;
brightnessSlider.value = [[UIScreen mainScreen] brightness];
brightnessSlider.continuous = YES;
[brightnessSlider addTarget:self action:#selector(adjustBrightness:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *brightSliderAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:brightnessSlider];
MPVolumeView *volView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
volView.showsRouteButton = NO;
UIBarButtonItem *volSliderAsToolbarItem = [[UIBarButtonItem alloc] initWithCustomView:volView];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *toc = [[UIBarButtonItem alloc] initWithTitle:#"Contents" style:UIBarButtonItemStyleBordered target:self action:#selector(goToToC)];
[toolBar setItems:[NSArray arrayWithObjects:modeSelectorAsToolbarItem, flexibleSpace, brightSliderAsToolbarItem, volSliderAsToolbarItem, flexibleSpace, toc, nil] animated:NO];
toolBar.autoresizingMask |= UIViewAutoresizingFlexibleWidth;
[[self view] addSubview:toolBar];
}
(Changing the CGRectMake coordinates doesn't seem to do anything.)
A comment in the question "Custom MPVolumeView Thumb Image not vertically centered since iOS 5.1" seemed to suggest using the "Fixing thumb alignment" trick explained here, but implementing that code didn't seem to do anything as far as I could tell, and I'm not sure whether it was talking about the same problem.
If you create a trivial subclass of MPVolumeView and override volumeSliderRectForBounds:, you can define your own alignment for the slider rect. I like to return the whole bounds, which centers the slider in the MPVolumeView's frame
#interface KMVolumeView : MPVolumeView
#end
#implementation KMVolumeView
- (CGRect)volumeSliderRectForBounds:(CGRect)bounds
{
return bounds;
}
#end
Just use your subclass in code or in interface builder and you can then reliably position the volume view.
I came up with something, that extends kmikael's answer:
#interface SystemVolumeView : MPVolumeView
#end
#implementation SystemVolumeView
- (CGRect)volumeSliderRectForBounds:(CGRect)bounds {
CGRect newBounds=[super volumeSliderRectForBounds:bounds];
newBounds.origin.y=bounds.origin.y;
newBounds.size.height=bounds.size.height;
return newBounds;
}
- (CGRect) routeButtonRectForBounds:(CGRect)bounds {
CGRect newBounds=[super routeButtonRectForBounds:bounds];
newBounds.origin.y=bounds.origin.y;
newBounds.size.height=bounds.size.height;
return newBounds;
}
#end
This implementation differs in that it still uses the default horizontal values but overrides the vertical ones in order to keep the MPVolumeView centered vertically in its container. It also overrides -routeButtonRectForBounds: so that the airplay/route button gets centered as well.
I have to wonder why the default implementation has a wonky vertical position.
SWIFT Version:
come form hyperspasm's answer:
import Foundation
class SystemVolumeView: MPVolumeView {
override func volumeSliderRect(forBounds bounds: CGRect) -> CGRect {
var newBounds = super.volumeSliderRect(forBounds: bounds)
newBounds.origin.y = bounds.origin.y
newBounds.size.height = bounds.size.height
return newBounds
}
override func routeButtonRect(forBounds bounds: CGRect) -> CGRect {
var newBounds = super.routeButtonRect(forBounds: bounds)
newBounds.origin.y = bounds.origin.y
newBounds.size.height = bounds.size.height
return newBounds
}
}
I ended up just using UISlider for both, using the instructions provided in the "Get System Volume" and "Change System Volume" answers to make a volume slider instead of using MPVolumeView.