漸變顯示漸變消失的BackgroundView

2021-09-06 18:31:02 字數 3442 閱讀 4854

漸變顯示漸變消失的backgroundview

效果如下:

原始碼:backgroundview.h 與 backgroundview.m

//

//testhud

////

created by youxianming on 14-9-30.

////

#import

@inte***ce

backgroundview : uiview

@property (nonatomic, assign) nstimeinterval startduration;

//動畫開始時持續時間

@property (nonatomic, assign) nstimeinterval endduration; //

動畫結束時持續時間

- (instancetype)initinview:(uiview *)view;

//開始附加到view中

- (void

)addtoview;

//將自己從view中移除掉

- (void

)removeself;

@end

//

//testhud

////

created by youxianming on 14-9-30.

////

#import

"backgroundview.h

"#ifdef

debug

#define backgroundview_dlog(fmt, ...) nslog((@"backgroundview.m:%s:%d" fmt), __pretty_function__, __line__, ##__va_args__);

#else

#define backgroundview_dlog(...)

#endif

@inte***ce

backgroundview ()

@property (nonatomic, weak) uiview *inview;

@end

@implementation

backgroundview

- (instancetype)initinview:(uiview *)view

return

self;

}- (void

)addtoview

[uiview animatewithduration:duration animations:^];

}- (void

)removeself

[uiview animatewithduration:duration animations:^ completion:^(bool finished) ];

}- (void

)dealloc

@end

category檔案:

//

//uiview+backgroundview.h

//backgroundview

////

created by youxianming on 14-10-3.

////

#import

#import

"backgroundview.h

"typedef

void (^configbackgroundviewblock)(backgroundview *configview);

@inte***ce

uiview (backgroundview)

- (void

)showbackgroundviewandconfig:(configbackgroundviewblock)block;

- (void

)removebackgroundview;

@end

//

//uiview+backgroundview.m

//backgroundview

////

created by youxianming on 14-10-3.

////

#import

"uiview+backgroundview.h

"#define tag_data 0x3d2894

@implementation

uiview (backgroundview)

- (void

)showbackgroundviewandconfig:(configbackgroundviewblock)block

backgroundview *backview =[[backgroundview alloc] initinview:self];

backview.tag =tag_data;

block(backview);

[backview addtoview];

}- (void

)removebackgroundview

}@end

使用的原始碼:

//

//backgroundview

////

created by youxianming on 14-10-3.

////

#import

"viewcontroller.h

"#import

"uiview+backgroundview.h

"@inte***ce

viewcontroller ()

@end

@implementation

viewcontroller

- (void

)viewdidload

- (void)tapevent:(uitapgesturerecognizer *)tap];

//延遲3s執行

[self performselector:@selector(affterdelay)

withobject:nil

afterdelay:

3.f];

}- (void

)affterdelay

@end

以下是需要注意的地方:

CSS 顯示漸變

css一些東西 這裡主要有乙個方法就是背景漸變,一般我們處理的時候是用 1.css匯入 第一種是把css文件放到 我們看到這裡應用了乙個,rel stylesheet 指連線的元素是乙個樣式表 stylesheet 文件。一般這裡 是不 需 要您改動的。就可以了。這種方法非常適宜同時定義多個文件。它...

Qt 控制項漸變隱藏消失

首先來看看效果圖 當然,還可以將 qlabel 換成其他控制項,比如 qpushbutton等等。來看原始碼 widget widget qwidget parent qwidget parent ui new ui widget widget widget void widget on pushb...

android 字型漸變顯示特效

mono裡面有一種效果是這樣的 列表滑動到某個位置時,中間的文字產生隨機動畫,雖然不是有規律性的錯落有致,但還是很有美感。mono的那種文字動畫,不能從傳統的動畫思路著手,因為傳統的動畫根本不支援。效果圖這兩天剛好專案不大緊張,所以就在空閒時間翻閱了相關資料,對要實現的效果進行了一些思考。然後,臨時...