创建简单的UISegment方法

UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:
                                       [NSArray arrayWithObjects:
                                        @"分类",@"标签",@"专题",
                                        nil]];
        segment.frame = CGRectMake(74, 5, 168, 33);
        [segment addTarget:self action:@selector(segmentClick:) forControlEvents:UIControlEventValueChanged];
        segment.segmentedControlStyle = UISegmentedControlStyleBar;
        segment.tintColor = [UIColor colorWithRed:41.0f/255.0f green:75.0f/255.0f blue:183.0f/255.0f alpha:1.0];
        segment.selectedSegmentIndex = 0;
        [self setXDSegment:segment];
        [segment release];

你可能感兴趣的:(创建简单的UISegment方法)