[Code Note] Click on the vertex to bring up another small interface, note Vertex

Source: Internet
Author: User

[Code Note] Click on the vertex to bring up another small interface, note Vertex

I ,.

 

2. File directory.

3. Code.

RootViewController. h

#import <UIKit/UIKit.h>@interface RootViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{    UIView * _huiView;    UITableView * _btnTableView;    UITableView * _tableView;}@end

 

RootViewController. m

# Import "RootViewController. h "@ interface RootViewController () @ end @ implementation RootViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // initialize the background image [self initBackGroundView];} # pragma-mark-functions-(void) initBackGroundView {// large tableView _ tableView = [[UITableView alloc] initWithFrame: CGRectMake (0,90, 320, self. view. bounds. size. height)]; _ tableView. delegate = self; _ tableView. dataSource = self; _ tableView. backgroundColor = [UIColor whiteColor]; [self. view addSubview: _ tableView]; // UIView _ huiView = [[UIView alloc] initWithFrame: CGRectMake (-320, 90,320, self. view. bounds. size. height)]; _ huiView. backgroundColor = [UIColor blueColor]; _ huiView. alpha = 0.9; _ huiView. layer. cornerRadius = 10; [self. view addSubview: _ huiView]; // triangle NSString * path = [[NSBundle mainBundle] pathForResource: @ "shangwu_shaixuan_sanjiaoxing" ofType: @ "png"]; UIImage * image = [[UIImage alloc] initWithContentsOfFile: path]; UIImageView * imageView = [[UIImageView alloc] initWithImage: image]; imageView. frame = CGRectMake (150, 12, 20, 15); [_ huiView addSubview: imageView]; // red line UIView * view = [[UIView alloc] initWithFrame: CGRectMake (10, 27,300, 3)]; view. backgroundColor = [UIColor redColor]; [_ huiView addSubview: view]; // tableView _ btnTableView = [[UITableView alloc] initWithFrame: CGRectMake (10, 30,300,200) style: UITableViewStylePlain]; _ btnTableView. delegate = self; _ btnTableView. dataSource = self; _ btnTableView. layer. cornerRadius = 10; [_ huiView addSubview: _ btnTableView];} # pragma-mark-UITableViewDelegate-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath {if (tableView ==_tableview) {return 100;} return 50;}-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {if (tableView ==_tableview) {return 100;} return 5;}-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {if (tableView ==_btntableview) {static NSString * cellName = @ "cellName"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: cellName]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellName];} if (indexPath. row = 0) {cell. textLabel. text = @ ""; return cell;} cell. textLabel. text = @ "Gourmet"; cell. textLabel. textColor = [UIColor blackColor]; return cell;} else {static NSString * cellName = @ "cell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: cellName]; if (cell = nil) {cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellName];} if (indexPath. row = 0) {cell. textLabel. text = @ ""; return cell;} cell. textLabel. text = @ "exercise"; cell. textLabel. textColor = [UIColor blackColor]; return cell ;}}-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath {NSLog (@ "---- didSelectRowAtIndexPath ----"); if (tableView = _ tableView) {[UIView animateWithDuration: 0.7 animations: ^ {_ huiView. frame = CGRectMake (0, 45 + 45,320, self. view. bounds. size. height) ;}] ;}else {[UIView animateWithDuration: 0.7 animations: ^ {_ huiView. frame = CGRectMake (-320, 45 + 45,320, self. view. bounds. size. height);}] ;}}-(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .}

 

 

Related Article

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.