zoukankan      html  css  js  c++  java
  • // Create a segmented control.

    // Create a segmented control.
    UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:nil];
    [segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"up_button.png"] atIndex:0 animated:YES];
    [segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"down_button.png"] atIndex:1 animated:YES];
    segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segmentedControl.frame = CGRectMake(0, 0, 90, 30);
    [segmentedControl setMomentary:YES];
    [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    // Check if this is the first and / or the last page in order to enable or disable the back / forward button.
    if ([recipesArray count] == 1) {
    [segmentedControl setEnabled:NO forSegmentAtIndex:0];
    [segmentedControl setEnabled:NO forSegmentAtIndex:1];
    } else if ([currentIndex intValue] == 0) {
    [segmentedControl setEnabled:NO forSegmentAtIndex:0];
    } else if ([currentIndex intValue]+1 == [recipesArray count]) {
    [segmentedControl setEnabled:NO forSegmentAtIndex:1];
    }
    // Initialize a bar button item with the segmented control as custom view and assign it to the right bar button item.
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
    self.navigationItem.rightBarButtonItem = barButtonItem;
    [segmentedControl release];
  • 相关阅读:
    探索c#之一致性Hash详解
    Redis系列(三)-Redis发布订阅及客户端编程
    Redis系列(二)-Hredis客户端设计及开源
    关于电脑操作一些高效的方法工具
    探索c#之递归APS和CPS
    探索C#之系列目录导航
    探索c#之不可变数据类型
    SOA相关资料整理分享
    探索c#之尾递归编译器优化
    探索c#之函数创建和闭包
  • 原文地址:https://www.cnblogs.com/chen1987lei/p/2067599.html
Copyright © 2011-2022 走看看