I want to create an UIView user interface design with some transparency as i have mention in first image:
First Image :
here is my code :
self.view.opaque = NO;
self.activityIndicatorView3.alpha = 0;
[self.view addSubview:self.activityIndicatorView3];
[self.activityIndicatorView3 startAnimating];
self.activityIndicatorView3.alpha = 1.0;
self.view.alpha = 0.15;
Using above code i am getting output as below output image :
here progress bar is not visible. I don't know, what i am doing wrong in my code. Please help me to achieve this. Thanks!
Actually you added the activity indicator in View.So if your decreasing the alpha of view,It will effect to its subviews also.For this you can use
self.view.opaque = NO;
self.activityIndicatorView3.alpha = 0;
[self.view addSubview:self.activityIndicatorView3];
[self.activityIndicatorView3 startAnimating];
self.activityIndicatorView3.alpha = 1.0;
self.view.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:.6];
You can reduce the alpha of view background color .
Setting the opacity for the superview will also affect its subviews.
The best way is to create a faded view for that effect
self.activityIndicatorView3.alpha = 0;
[self.view addSubview:self.activityIndicatorView3];
[self.activityIndicatorView3 startAnimating];
self.activityIndicatorView3.alpha = 1.0;
// Change this self.view.alpha = 0.15; to following code
UIView *fadedView=[[UIView alloc]initWithFrame:self.view.bounds];
[fadedView setBackgroundColor:[UIColor blackColor]];
[fadedView setAlpha:0.15];
[self.view addSubview:fadedView];
[self.view sendSubviewToBack:fadedView];
Related
I loaded a pdf in a scrollview, and I would like to go directly to the next page without having the animation scrolling.
CGRect scrollViewRect = CGRectInset(viewRect, -scrollViewOutset, 0.0f);
theScrollView = [[UIScrollView alloc] initWithFrame:scrollViewRect]; // All
theScrollView.autoresizesSubviews = NO;
theScrollView.contentMode = UIViewContentModeRedraw;
theScrollView.showsHorizontalScrollIndicator = NO;
theScrollView.showsVerticalScrollIndicator = NO;
theScrollView.scrollsToTop = NO;
theScrollView.delaysContentTouches = NO;
theScrollView.pagingEnabled = YES;
theScrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
theScrollView.backgroundColor = [UIColor clearColor];
theScrollView.delegate = self;
[self.view addSubview:theScrollView];
Is it possible ?
You have to use below method to jump on direct offset of your next page by below method.
[objUIScrollView setContentOffset:CGPointMake(YOUR_X, YOUR_Y) animated:NO]
animated = NO;
If you are loading PDF through WebView than you need to follow below code:
webview.scrollView.contentOffset = CGPointMake(YOUR_X, YOUR_Y);
Note : Use this above code in your Next Button page or after loading
WebView properly may be in below method.
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
}
Hope this will work as you expected.
Sure, simply use:
[theScrollView scrollRectToVisible:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f) animated:NO];
or
[theScrollView setContentOffset:CGPointMake(0.0f, 0.0f) animated:NO];
and change the CGPoint or CGRect to the offset of the page of your liking.
I have a UIView in which i want to remove the whole background so it would take the shape of a paper. I tried setting the background to transparent from the UI and using the code but i always end up with a gray-like semi transparent background no matter what i do. Here is the current output i am getting :
How can i remove that grey background? i need it to display as a whole paper without that residue. Any Help? I tried the following :
// self.view.backgroundColor = [UIColor clearColor];
//
// [self.view setOpaque:YES];
//
// self.view.backgroundColor = [UIColor clearColor];.
// self.view.layer.borderWidth = 0.0;
// self.view.layer.masksToBounds = YES;
// self.view.backgroundColor=[[UIColor clearColor] colorWithAlphaComponent:.0];
And the current UI Configuration is :
How can i manage to remove it !? Any help!?
EDIT 1
This is the new output
Looks like your image it's inside a Modal View. If that is the case try the following:
Set the self.view.superview.backgroundColor to [UIColor clearColor]; inside the viewWillLayoutSubviews
Example
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.view.superview.layer.masksToBounds = YES;
self.view.superview.backgroundColor = [UIColor clearColor];
}
I am using a UIWebview,but there is some black background behind the web view in ios8. The same is working fine in ios7. I also set opaque to NO.
Try adding UIWebview as subview programmatically.
WebView = [[UIWebView alloc]initWithFrame:CGRectMake(264, 10, 745, 576)];
WebView.userInteractionEnabled = YES;
[self setBorderToView: WebView];
WebView.scrollView.bounces = NO;
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setOpaque:NO];
[WebView loadHTMLString: embedHTML baseURL: nil];
[self.view addSubview: WebView];
Hope this helps you!
I also faced same issue, after not getting proper solution I did a trick using Masking.
CALayer *aLayer = [CALayer layer];
aLayer.backgroundColor = [UIColor blackColor].CGColor;
aLayer.frame = CGRectMake(origin.x, origin.y, widthOfVideo, heightOfVideo);
objWebView.layer.mask = aLayer;
And This worked for me. Hope that can be helpful to you.
Put a instance variable in the in the header file or your class:
// instance variable for interval timer
NSTimer *BackgroundIntervalTimer;
Put these methods in the implementation file:
- (void)startUIWebViewBackgroundFixTimer {
// if > iOS 8 start fixing background color of UIWebPDFView
if (!SYSTEM_VERSION_LESS_THAN(#"8.0")) {
// hide pdfWebView until background fixed
self.pdfWebView.alpha = 0.0;
// start interval timer
BackgroundIntervalTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:#selector(fixBackground) userInfo:nil repeats:YES];
}
}
- (void)stopUIWebViewBackgroundFixTimer {
[BackgroundIntervalTimer invalidate];
BackgroundIntervalTimer = nil;
}
- (void)fixBackground {
// stop timer interval
[self stopUIWebViewBackgroundFixTimer];
// Assuming self.webView is our UIWebView
// We go though all sub views of the UIWebView and set their backgroundColor to white
UIView *v = self.pdfWebView;
while (v) {
//v.backgroundColor = [UIColor whiteColor];
v = [v.subviews firstObject];
if ([NSStringFromClass([v class]) isEqualToString:#"UIWebPDFView"]) {
[v setBackgroundColor:[UIColor whiteColor]];
// background set to white so fade view in and exit
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.pdfWebView.alpha = 1.0;
}
completion:nil];
return;
}
}
// UIWebPDFView doesnt exist yet so exit and try later
[self startUIWebViewBackgroundFixTimer];
}
Now put this line right after the line where you load the pdf:
// if iOS 8 check if pdfWebView got subview of class UIWebPDFView
[self startUIWebViewBackgroundFixTimer];
I am trying to give the flip effect to a UIview as if on one side I had some content and on the other side I had some other in the following way:
[UIView transitionWithView:FlipView duration:0.7
options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
//imageView.image = secondImage;
FlipImage.hidden = YES;
for (UIButton *btn in arrayoflabels) {
btn.hidden = YES;
}
containerViewSplashit.hidden = NO;
containerViewSplashit.alpha = 1.0;
closeButton.hidden = NO;
} completion:nil];
The only problem is that it flips and then when it finishes flipping, it shows the hidden content I want to show, but it doesn't give that front to back effect that it swops side when it passes the middle. how can i fix this?
You should try to ad the UIViewAnimationOptionAllowAnimatedContent option to the animation option because you have animatable changes in your block (hidden, alpha).
I have a view I change the background of as the state of the application changes. Basically I want the view background changes to animate in some sort of a slide. I've been looking for a solution, but haven't really found anything.
So I want to have a transition from whatever the current background is to the next one.
//current to:
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
I have no trouble getting the background to change but I would like to animate it. Any help in the right direction would be greatly appreciated thanks.
You can use this:
[UIView animateWithDuration:1
delay:0
options:UIViewAnimationOptionAutoreverse
animations:^
{
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
}
completion:nil
];
a very easy way to handle it:
such as yourView.backgroundColor = [UIColor redColor];
Then use this to animate change the color
#import <QuartzCore/QuartzCore.h>
yourView.backgroundColor = [UIColor blueColor];
CATransition *transiton = [[CATransition alloc] init];
transiton.duration = .5;
[yourView.layer addAnimation:transiton forKey:#"Animation"];
Just a simple animation block:
[UIView animateWithDuration:time animations^{
self.view.backgroundColor = [UIColorWithPatternImage:image];
}];
this just animates the transfer, taking time seconds.