2012-03-02 37 views

回答

3

爲什麼不添加另一個UIView並在某些事件上將其添加到UIView

+0

我有一個搜索欄,當用戶點擊它時,我使用CATransition向上移動它,並顯示取消按鈕。現在,在此之後,我希望其餘的視圖下面的搜索欄blackish..sort像Twitter應用程序..#發現選項卡 – 2012-03-02 12:36:53

+0

顯示一些圖像 – Sarah 2012-03-02 12:37:54

1

添加的UIImageView與黑色背景:

UIImageView *myView= [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)]; 
    myView.backgroundColor = [UIColor blackColor]; 
    [self.view addSubview:myView]; 
    [myView release]; 
1

它可以通過以下面的方式

的UIView *視圖= [[[UIView的頁頭添加子層到視圖的層來完成] initWithFrame:CGRectMake(50.0,0.0,100.0,100.0)] autorelease]; view.backgroundColor = [UIColor grayColor]; [self.view addSubview:view];

CALayer *layerUP = [CALayer layer]; 
[layerUP setFrame:CGRectMake(0.0, 0.0, 100.0, 50.0)]; 
[layerUP setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor]; 
[view.layer addSublayer:layerUP]; 

CALayer *layerDown = [CALayer layer]; 
[layerDown setFrame:CGRectMake(0.0, 50.0, 100.0, 50.0)]; 
[layerDown setBackgroundColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2].CGColor]; 
[view.layer addSublayer:layerDown];