0
我想創建我自己的自定義顯示案例視圖,其中我有左鍵,右鍵和標籤欄視圖。創建顯示案例視圖在Tabbar xcode
我想突出顯示與它周圍的圓形按鈕。 我可以通過子類UIView 在我的按鈕周圍創建一個圓圈。但是,我這樣做的用戶從左到右滑動,它會將圓圈更改爲右側按鈕,左側按鈕隱藏。 這裏是我的UIView
//--------.h類的子類
#import <UIKit/UIKit.h>
@interface IntroView : UIView
- (void)drawRect:(CGRect)rect withBtnRect:(CGRect)btnrect ;
@end
// ------。米類
#import "IntroView.h"
@implementation IntroView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
self.backgroundColor= [[UIColor blackColor] colorWithAlphaComponent:0.3];
return self;
}
- (void)drawRect:(CGRect)rect {
CGRect maskRect= CGRectMake(5, 5, 100, 100);//set and pass this maskRect
CGRect rBounds = self.bounds;
CGContextRef context = UIGraphicsGetCurrentContext();
// Fill background with 40% gray
CGContextSetFillColorWithColor(context, [[[UIColor grayColor] colorWithAlphaComponent:0.4] CGColor]);
CGContextFillRect(context, rBounds);
// Draw the window 'frame'
CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextSetLineWidth(context,2);
CGContextStrokeEllipseInRect(context, maskRect);
// make the window transparent
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextFillEllipseInRect (context, maskRect);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
而我的TabBar第一視圖內我請使用
#import "IntroView.h"
然後
- (void)viewDidLoad
{
IntroView *vw_intro=[[IntroView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
vw_intro.tag=1000;
[self.view addSubview:vw_intro];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
這是我的輸出
和預期輸出幻燈片上從右至左,所以還是反向(就像我們做showcase android library)
感謝一個漂亮又快速的答案,我會將它轉換爲圓形並很快發佈 – iphonemaclover