I am Using Circular slider in three classes. where i have three different Slider images and i want to add Circular Slider view (which is inherit from UIVIEW) on uiimageview.
This is my code:::
CircularSliderView *sliderView = [[CircularSliderView alloc] initWithMinValue:0 maxValue:100 initialValue:0];
sliderView.backgroundColor=[UIColor clearColor];
sliderView.frame=CGRectMake(88,160, 140, 150);
[self.view addSubview:sliderView];
It is not Working. if i adding it on Main view. it is working Properly.
I really don't know how it is going like this,please help me out!
if you are adding sliderView in self.imageview
[self.imageview addSubview:sliderView];
then write
self.imageview.userInteractionEnabled = true
By default UIImageview user interaction is disable
i hope this will work
Related
For prototyping I am looking to create a invisible interaction area.
If I set the alpha to 0, you can't interact withit.
If you set it to
hidden, it also does not receive gesture events.
Why do you want to use a View for this, Instead you could just use a UIButton and set frame to your current view's frame & set its background color to clearColor like below,
self.invisibleButton.backgroundColor = [UIColor clearColor];
This will do the same action & reduce little works like adding Tap gesture and setting some properties for the view if you go with View.
The best solution I have found is to set the background color to an invisible color. You can't see the button but you can interact with it.
In the init I put:
self.backgroundColor = UIColor.blueColor().colorWithAlphaComponent(0)
Is there any better way to do this?
Create a UIView enable userInteraction and make clear background color
UIView *viewsample=[[UIView alloc]init];
viewsample.frame= CGRectMake(0, 0, 200, 200);
viewsample.backgroundColor= [UIColor clearColor];
viewsample.userInteractionEnabled=YES;
[self.view addSubview:viewsample];
UITapGestureRecognizer *tapSkip = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(iviewsampleClicked:)];
[viewsample addGestureRecognizer:tapSkip];
method called when it touched
-(void)iviewsampleClicked:(UIGestureRecognizer*)gesture{
}
I'm creating UIView programmatically and called this UIView captureImage. This UIView captureImage display the image that I capture from camera and the parentView I called it self.frameForCapture. But the problem is, It always overlap the UIView that I add to the storyboard.
Update Post:
Here is the image that I'm trying to make in my app.
Black View is my parentView and I called it self.frameForCapture.
Blue View is childView, and I add it using the storyboard.
Red View is childView, and I programmatically added to the parentView.
But the time I add it the redView. It always overlap the blueView, i use this addSubView:.
But if I used these
[self.frameForCapture bringSubviewToFront:captureImage];
[self.frameForCapture sendSubviewToBack:captureImage];
nothing happen.
I used this code:
self.newalbumImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.newalbumImageView setContentMode:UIViewContentModeScaleAspectFill];
self.newalbumImageView.image = self.albumImage;
UIView * captureImage = [[UIView alloc] initWithFrame:self.frameForCapture.frame];
[captureImage addSubview:self.newalbumImageView];
[self.frameForCapture addSubview:captureImage];
there are a few things that can help you look at this question How to make a UIView always appear at the front?
just link the headerview to .h file and use myAlwaysOnTopView.layer.zPosition = MAXFLOAT;
another thing is that when you use [self.frameForCapture sendSubviewToBack:captureImage];
the redview will still be on top of self.frameForCapture if don't want it like that you can hide it or even remove
if you still have this problem just tag me
I have a really large image that I want to use as a background image of a view. However, I don't want to display the entire image at once; I want only a part of the image to be displayed, and then I want to animate it to display other parts of it, similar to the "infinite background" in games (only not infinite in my case ;)).
What is the best way to do this? Will I have to separate the image in several pieces and then somehow animate the transition between the pieces, or is there a better way?
How about having UIScrollView as a background view? You can then put UIImageView inside that scroll view and control scroll view's contentOffset as needed.
I found the solution. This piece of code does the magic:
self.backgroundImageView = [[UIImageView alloc] initWithFrame: self.view.bounds];
self.backgroundImageView.image = [UIImage imageNamed:#"background.png"];
self.backgroundImageView.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview: self.backgroundImageView];
The key was setting the contentMode to UIViewContentModeBottomLeft.
I´m build a swipe feature for my todo-list application. When a user swipes(drag) the cell horizontally I would like to display a background image that covers the gap between the screen edge and the cell edge.
When I add an image to the imageView-property it just follows the cell. Can I somehow fix it to cover the whole background?
It sounds like you want to make something like Clear.
What you will need to do is:
Subclass UITableViewCell
Add your image view like this..
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
imageView.image = myImage;
[self insertSubview:imageView atIndex:0]; //I'm not at a compiler, so I'm not 100% on this, but it's something like this.
Add a UIGestureRecognizer to handle gestures, and set up dragging and appropriate actions.
I'm currently making a photo decoration app. The *holderView is the sticker that has been chosen by user. Whenever I try to load a photo from photo library or take a photo and then load back to this page, additional *holderView added programmatically, which is the sticker that I've previously chosen before taking a photo, duplicated sticker appears after that, which is not what I want it to be.
How should I write the code for not letting this happen?
Thanks a lot.
- (void)viewWillAppear:(BOOL)animated {
UIView *holderView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, _imagePicker.selectedImage.size.width, _imagePicker.selectedImage.size.height)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[holderView frame]];
[imageView setImage:_imagePicker.selectedImage];
[holderView addSubview:imageView];
...
}
Your problem seems to be that your using the viewWillAppear method instead of the viewDidLoad. This will cause multiple "imageViews" because your adding a new one every time you hide then show the viewController it's presented in. what you want to do is move the creation of the imageView (if there really is suppose to only be 1) to the viewDidLoad method and make that imageView accessible to the entire class, then in the viewWillApear simply change the image inside the imageView to the newly selected one.