IOS, view-related

Source: Internet
Author: User

1. Removing the view's child view

2. Custom View (UIView)

3. Handle hover window (similar video), equal to zoom

Removes the view's child view

[[Self.viewsubviews]makeobjectsperformselector: @selector (Removefromsuperview)];

Or

Nsarray *viewstoremove = [Self.view subviews];

For (UIView *v in Viewstoremove) {

[v Removefromsuperview];

}

Custom View (UIView)

FACEVIEW.M file
@implementation Faceview

-(ID) initWithFrame: (CGRect) frame{

Self=[super Initwithframe:frame];

if (self) {

}

return self;

}


Self-implementation of the DrawRect method redraw, or can not implement the method, its own definition of execution interface processing method execution
-(void) DrawRect: (cgrect) rect{//Omit implementation ...


} @end

Handle suspended Windows (similar to video), zoom

The view that will be loaded is placed on the main window or on the root view controller, using transform to zoom

The following is a view that is processed in appdelegate

Floatingview *view=[[floatingview Alloc] Initwithframe:cgrectmake (50, 50, 200, 200)];

// Add a drag gesture to make the view drag in the hover window

Uipangesturerecognizer *pangestures=[[uipangesturerecognizer Alloc] initwithtarget:self action: @selector ( Handlepangestures:)];

[View Addgesturerecognizer:pangestures];

//Click View gestures

UITapGestureRecognizer *tapgestures=[[uitapgesturerecognizer Alloc] initwithtarget:self action: @selector ( Narrowview:)];

[View Addgesturerecognizer:tapgestures];

[Self.window Addsubview:view];

Click Equal to zoom Out view

-(void) Narrowview: (UITapGestureRecognizer *) sender{

//Equal ratio zoom view

Sender.view.transform=cgaffinetransformscale (Sender.view.transform, 0.5, 0.5);

}

Handling Video View Drag events

-(void) Handlepangestures: (Uipangesturerecognizer *) sender{

if (sender.state!=uigesturerecognizerstateended&&sender.state!=uigesturerecognizerstatefailed) {

//Use the Locationinview method to get the coordinates of the gesture

Cgpoint Location=[sender LocationInView:sender.view.superview];

Sender.view.center=location;

}

}

IOS, view-related

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.