mpmovieplayer not setting background in ios6 - ios

This code does not set the background view of a MPMoviePlayerController in iOS6 but works perfectly in iOS7.
UIView *patternView = [[UIView alloc] initWithFrame:self.view.bounds];
patternView.backgroundColor = [UIColor redColor];
UIImageView *imgView=[[UIImageView alloc]initWithFrame:self.view.bounds];
imgView.image=imgBackGround;
[patternView addSubview:imgView];
[self.moviePlayer.backgroundView addSubview:patternView];
What is the alternative?

You are ultimately setting the view with background color red.If you only wants set the background color,then instead of taking any view and adding it, set its MPMoviePlayerController view's background color directly.
[self.moviePlayer.view setBackgroundColor:[UIColor redColor]];

Related

UITableView background color iOS 9

I have a UITableView that I want to set its background color to transparent. Background color for the table view and all subviews at interface builder is set to transparent. It works fine for iOS 8 & 7. but, not iOS 9. any idea?
cellForRowAtIndexPath method:
[cell setSelectedBackgroundView:[[UIView alloc] init]];
[cell.selectedBackgroundView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundColor:[UIColor clearColor]];
[cell.contentView setBackgroundColor:[UIColor clearColor]];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView setBackgroundColor:[UIColor clearColor]];
Objective-c:
[self.yourTableView setBackgroundColor:[UIColor clearColor]];
Swift:
self.yourTableView.backgroundColor = .clear
XCode 7.0 bug. Not picking up from Storyboard
This happens to me even when creating an UITableView in code, and setting it as a private property of my UIViewController. However, if the UITableView is a global variable, this problem does not occur.
I suspect Apple is rooting around the ivars on my UIViewController, setting UITableView's background colors to UIColor whiteColor without asking me. I have checked, and the calls to do go through setBackgroundColor on the UITableView.

How to present 'UIViewController' in Cocoas2D with custom size

Imagine I have dialog and size of this dialog is 200x200 and I want to present on the iPhone screen temporary (can dismiss with button).
I try it. but the view controller that I presented is replace current scene (dialog and white background border).
I want to present with custom size (200x200) at center of iPhone screen and see my content as background
I try to set dialog's background colour to clearColor and It doesn't work.
Thanks in advance.
Create your button like this,
[button addTarget:self action:#selector(ButtonFun) forControlEvents:UIControlEventTouchUpInside];
-(void)ButtonFun {
UIView *newView1 = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
newView1.backgroundColor = [UIColor whiteColor];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
textView.text = #"Write your dialog";
[textView setFont:[UIFont fontWithName:#"ArialMT" size:15]];
textView.textAlignment = NSTextAlignmentCenter;
[newView1 addSubview:textView];
newView1.center = self.view.center;
[self.view addSubview:newView1];
}
To remove this UIView use UITapGestureRecognizer,or simply
[newView1 removeFromSuperview];

Resize background color/image base on new UIView's size?

How to make the view's background color change base on the size of view? I can re-size the view but seem the background color not change, it's fixed.
color = [view backgroundColor];
[view setBackgroundColor:[UIColor clearColor]];
[view setFrame:rect];
[view setBackgroundColor:color];
You have set the background color of view to ClearColor , So it's not being changed.
Try,
color = [view backgroundColor];
[view setBackgroundColor:[UIColor clearColor]];
[view setFrame:rect];
// here you need to set the
color = [UIColor redColor]; // or the color you want to change
[view setBackgroundColor:color];
Implement the setFrame Method of the View then only Your Change background color will be called when ever you change the size of View....
Make subclass of a UIView and implement setFrame Method.
-(void)setFrame:(CGRect)frame{
self = [super setFrame:frame];
self.backgroundColor = [UIColor redColor];
//Put any condition here for specific background color using frame property of view
}

UIImageView backgroundColor colorWithPatternImage not showing

I'm having an issue with UIImageView that's not quite making sense to me. I want to set the image of the UIImageView and have it appear above the patterned image I've set to the background. This occurs correctly if the background color is a standard color: [UIColor whiteColor], but as soon as set it to a patternImage the background becomes completely transparent. This is kind of frustrating. I can get around it by creating another view, setting the backgroundColor of it to a patternImage, and then adding the UIImageView as a subview, but that's creating an extra view that should be unnecessary, IMO. Here's my code:
UIImageView *view = [[UIImageView alloc] initWithFrame:_standardRect];
view.image = _connectIcon;
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: #"background.jpg"]];
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
return view;
Doing this works on iOS 5.1:
view.layer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: #"background.jpg"]].CGColor;
However, the bug is gone on iOS 6.

Shadow under UIActivityIndicator on iPhone/iPad

I want to create shadow under animated UIActivityIndicator to display that other ui elements are inactive, like shadow under keyboard or alert-view. What is the best way to do this?
Add a view with a black background and opacity to 50% with something like this :
UIView *shadowView = [[UIView alloc] initWithFrame:yourFrame];
[shadowView setBackgroundColor:[UIColor blackColor]];
[shadowView setOpacity:0.5];
[yourCurrentView addSubview:shadowView];
[yourCurrentView bringSubviewToFront:yourActivityIndicator];

Resources