if (SecondaryTile.Exists(appbarTileId)) { SecondaryTile secondaryTile = new SecondaryTile(appbarTileId); bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above); } else { Uri logo = new Uri("ms-appx:///images/150.png"); string tileActivationArguments = appbarTileId + " was pinned at " + DateTime.Now.ToLocalTime().ToString(); SecondaryTile secondaryTile = new SecondaryTile(appbarTileId, "how do you think?", "what it is?", tileActivationArguments, TileOptions.ShowNameOnLogo, logo); secondaryTile.ForegroundText = ForegroundText.Dark; secondaryTile.SmallLogo = new Uri("ms-appx:///images/150.png"); bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Above); } private Rect GetElementRect(FrameworkElement frameworkElement) { GeneralTransform buttonTransform = frameworkElement.TransformToVisual(null); Point point = buttonTransform.TransformPoint(new Point()); return new Rect(point, new Size(frameworkElement.ActualWidth, frameworkElement.ActualHeight)); }
参考链接:http://msdn.microsoft.com/zh-CN/library/windows/apps/xaml/Hh868249(v=win.10).aspx
原本以為使用performSegueWithIdentifier就可以輕鬆切換ViewController,沒想到一直發生錯誤
原來是要在IB中的segue的identifier寫下identifier,否則會錯誤
另外在stept3 的部分可以設定過場的畫面
- (IBAction)GoViewButton01:(id)sender { [self performSegueWithIdentifier:@"ViewController01" sender:sender]; }
在公用类里写:
#import "Until.h"
#import "MCSegmentedControl.h"
@implementation Until
//共8个参数。
+(void)creatMySegment:(UIViewController *)viewController contentArray:(NSArray *)contentArray frame:(CGRect)frame selectedIndex:(int)selectedIndex selectedBgColor:(UIColor *)selectedBgColor unSelectedBgColor:(UIColor *)unSelectedBgColor selectedTextColor:(UIColor *)selectedTextColor unSelectedTextColor:(UIColor *)unSelectedTextColor{
MCSegmentedControl *segmentedControl = [[MCSegmentedControl alloc] initWithItems:contentArray];
segmentedControl.frame = frame;
segmentedControl.selectedSegmentIndex = selectedIndex;
segmentedControl.tintColor = selectedBgColor;//选中按钮的背景颜色。
segmentedControl.unSelectedItemBackgroundGradientColors = [NSArray arrayWithObjects:
unSelectedBgColor,
unSelectedBgColor,
nil];//没有选中按钮的背景颜色。
segmentedControl.selectedItemColor = selectedTextColor;//选中按钮文字的颜色。
segmentedControl.unselectedItemColor = unSelectedTextColor;//没有选中按钮文字的颜色。
[segmentedControl addTarget:viewController action:@selector(segmentedControlDidChange:) forControlEvents:UIControlEventValueChanged];
[viewController.view addSubview:segmentedControl];
[segmentedControl release];
}
@end
在需要用到的类里写:
- (void)viewDidLoad
{
[super viewDidLoad];
[Until creatMySegment:self contentArray:[NSArray arrayWithObjects:
@"one",
@"two",
[UIImage imageNamed:@"star.png"],
nil] frame:CGRectMake(10.0f, 208.0f, 300.0f, 44.0f) selectedIndex:0 selectedBgColor:[UIColor redColor] unSelectedBgColor:[UIColor blueColor] selectedTextColor:[UIColor whiteColor] unSelectedTextColor:[UIColor blackColor]];
}
- (void)segmentedControlDidChange:(MCSegmentedControl *)sender
{
NSLog(@"%d", [sender selectedSegmentIndex]);
}
当然还需要一个写好的方法。
下面有demo。。。。。。