UiSlider,UISegmentedControl和UIScreenEdgePanGestureRecognizer(手勢:左劃屏)

@implementation MainViewController

-(void)dealloc

{

    [superdealloc];

}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

   self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];

   if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [superviewDidLoad];

// Do any additional setup after loading the view.

    

   UISlider * slider = [[UISlideralloc ]initWithFrame:CGRectMake(50,50, 200, 15)];

    

    //按鈕左面和右面的顏色

    [slider setMaximumTrackTintColor:[UIColorblackColor]];

    [slider setMinimumTrackTintColor:[UIColorredColor]];

    //按鈕添加照片

    [slider setThumbImage:[UIImageimageNamed:@"1.png"]forState:UIControlStateNormal];

    

    [self.viewaddSubview:slider];

    [sliderrelease];

    

    

    NSArray * array = [[NSArrayalloc]initWithObjects:@"輕拍",@"長按",@"清掃",@"旋轉",@"捏合",@"拖拽",nil];

    UISegmentedControl *  control = [[UISegmentedControlalloc]initWithItems:array];

    

    //背景顏色

    [control setBackgroundColor:[UIColorblueColor]];

    control.alpha =0.5;

    

    //框顏色

    [control setTintColor:[UIColoryellowColor]];

    [controlsetFrame:CGRectMake(0,self.view.frame.size.height -40, 320, 40)];

    [self.viewaddSubview:control];

    [controlrelease];

    

    //添加事件

    UIScreenEdgePanGestureRecognizer * screen = [[UIScreenEdgePanGestureRecognizeralloc]initWithTarget:selfaction:@selector(screenAction:)];

    

    //左邊滑動

    screen.edges =UIRectEdgeLeft ;

    

    [self.viewaddGestureRecognizer:screen];

    [screenrelease];

    

//    [self.view removeGestureRecognizer:screen];

    

}




-(void)screenAction:(UIScreenEdgePanGestureRecognizer *)screen

{

    

   UIView * view = [[UIViewalloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width/2,self.view.frame.size.height)];

    [view setBackgroundColor:[UIColororangeColor]];

    [self.viewaddSubview:view];

    [viewrelease];


   

    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(50, 150, 200, 50)];

    [label setTextAlignment:NSTextAlignmentCenter];

    [label setText:@"05:45"];

    [label setTextColor:[UIColor whiteColor]];

    UIFont * font = [UIFont boldSystemFontOfSize:65];

    [label setFont:font];

    [view addSubview:label];

    [label release];




    

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章