本文整理汇总了C#中NSString类的典型用法代码示例。如果您正苦于以下问题:C# NSString类的具体用法?C# NSString怎么用?C# NSString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSString类属于命名空间,在下文中一共展示了NSString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: showSheetForWindow
public void showSheetForWindow(NSWindow aWindow) withMessage(NSString aMessage) allowCancel(bool aAllowCancel)
{
window = aWindow;
messageText = aMessage;
allowCancel = aAllowCancel;
NSApp.beginSheet(window) modalForWindow(window) modalDelegate(this) didEndSelector(__selector(didEndSheet:returnCode:contextInfo:)) contextInfo(null);
}
开发者ID:remobjects,项目名称:TwinPeaks,代码行数:7,代码来源:TPBusySheetController.cs
示例2: AddSiteUrl
public void AddSiteUrl(RectangleF frame)
{
url = UIButton.FromType(UIButtonType.Custom);
url.LineBreakMode = UILineBreakMode.TailTruncation;
url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
url.TitleShadowOffset = new SizeF(0, 1);
url.SetTitleColor(UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal);
url.SetTitleColor(UIColor.Red, UIControlState.Highlighted);
url.SetTitleShadowColor(UIColor.White, UIControlState.Normal);
url.AddTarget(delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside);
// Autosize the bio URL to fit available space
var size = _urlSize;
var urlFont = UIFont.BoldSystemFontOfSize(size);
var urlSize = new NSString(_bio.Url).StringSize(urlFont);
var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250;
while(urlSize.Width > available)
{
urlFont = UIFont.BoldSystemFontOfSize(size--);
urlSize = new NSString(_bio.Url).StringSize(urlFont);
}
url.Font = urlFont;
url.Frame = new RectangleF ((float)_left, (float)70, (float)(frame.Width - _left), (float)size);
url.SetTitle(_bio.Url, UIControlState.Normal);
url.SetTitle(_bio.Url, UIControlState.Highlighted);
AddSubview(url);
}
开发者ID:modulexcite,项目名称:artapp,代码行数:28,代码来源:BioView.cs
示例3: Draw
public override void Draw(CGRect rect)
{
base.Draw(rect);
var inset = this.TextContainerInset;
var leftInset = inset.Left + this.TextContainer.LineFragmentPadding;
var rightInset = inset.Left + this.TextContainer.LineFragmentPadding;
var maxSize = new CGSize()
{
Width = this.Frame.Width - (leftInset + rightInset),
Height = this.Frame.Height - (inset.Top + inset.Bottom)
};
var size = new NSString(this.Placeholder).StringSize(this.PlaceholderFont, maxSize, UILineBreakMode.WordWrap);
var frame = new CGRect(new CGPoint(leftInset, inset.Top), size);
this.placeholderLabel = new UILabel(frame)
{
BackgroundColor = UIColor.Clear,
Font = this.PlaceholderFont,
LineBreakMode = UILineBreakMode.WordWrap,
Lines = 0,
Text = this.Placeholder,
TextColor = this.PlaceholderColor
};
this.Add(this.placeholderLabel);
}
开发者ID:robert-waggott,项目名称:Xamarin.PlaceholderEnabledUITextView,代码行数:27,代码来源:PlaceholderEnabledUITextView.cs
示例4: NativeiOSListViewCell
public NativeiOSListViewCell(NSString cellId)
: base(UITableViewCellStyle.Default, cellId)
{
SelectionStyle = UITableViewCellSelectionStyle.Gray;
ContentView.BackgroundColor = UIColor.FromRGB(218, 255, 127);
imageView = new UIImageView();
headingLabel = new UILabel()
{
Font = UIFont.FromName("Cochin-BoldItalic", 22f),
TextColor = UIColor.FromRGB(127, 51, 0),
BackgroundColor = UIColor.Clear
};
subHeadingLabel = new UILabel()
{
Font = UIFont.FromName("AmericanTypewriter", 12f),
TextColor = UIColor.FromRGB(38, 127, 0),
TextAlignment = UITextAlignment.Center,
BackgroundColor = UIColor.Clear
};
ContentView.Add(headingLabel);
ContentView.Add(subHeadingLabel);
ContentView.Add(imageView);
}
开发者ID:ArtemKumeisha,项目名称:MyXamarin,代码行数:28,代码来源:NativeiOSListViewCell.cs
示例5: RegisterDefaultSettings
public static void RegisterDefaultSettings ()
{
var path = Path.Combine(NSBundle.MainBundle.PathForResource("Settings", "bundle"), "Root.plist");
using (NSString keyString = new NSString ("Key"), defaultString = new NSString ("DefaultValue"), preferenceSpecifiers = new NSString ("PreferenceSpecifiers"))
using (var settings = NSDictionary.FromFile(path))
using (var preferences = (NSArray)settings.ValueForKey(preferenceSpecifiers))
using (var registrationDictionary = new NSMutableDictionary ()) {
for (nuint i = 0; i < preferences.Count; i++)
using (var prefSpecification = preferences.GetItem<NSDictionary>(i))
using (var key = (NSString)prefSpecification.ValueForKey(keyString))
if (key != null)
using (var def = prefSpecification.ValueForKey(defaultString))
if (def != null)
registrationDictionary.SetValueForKey(def, key);
NSUserDefaults.StandardUserDefaults.RegisterDefaults(registrationDictionary);
#if DEBUG
SetSetting(SettingsKeys.UserReferenceKey, debugReferenceKey);
#else
SetSetting(SettingsKeys.UserReferenceKey, UIDevice.CurrentDevice.IdentifierForVendor.AsString());
#endif
Synchronize();
}
}
开发者ID:colbylwilliams,项目名称:Nomads,代码行数:27,代码来源:Settings.cs
示例6: CharacterSetWithCharactersInString
public static NSCharacterSet CharacterSetWithCharactersInString(NSString aString)
{
NSMutableCharacterSet ms = (NSMutableCharacterSet)NSMutableCharacterSet.Alloc().Init();
ms.AddCharactersInString(aString);
return ms;
}
开发者ID:smartmobili,项目名称:CocoaBuilder,代码行数:7,代码来源:NSCharacterSet.cs
示例7: QuoteTableCustomCell
public QuoteTableCustomCell(NSString cellId)
: base(UITableViewCellStyle.Default, cellId)
{
SelectionStyle = UITableViewCellSelectionStyle.Gray;
ContentView.BackgroundColor = UIColor.White;
price = new UILabel () {
Font = UIFont.FromName("AmericanTypewriter", 22f),
TextColor = UIColor.FromRGB (127, 51, 0),
TextAlignment = UITextAlignment.Center,
BackgroundColor = UIColor.Clear
};
position = new UILabel () {
Font = UIFont.FromName("AmericanTypewriter", 16f),
TextColor = UIColor.FromRGB (38, 127, 0),
TextAlignment = UITextAlignment.Center,
BackgroundColor = UIColor.Clear
};
time = new UILabel () {
Font = UIFont.FromName("AmericanTypewriter", 10f),
TextColor = UIColor.FromRGB (38, 88, 0),
TextAlignment = UITextAlignment.Center,
BackgroundColor = UIColor.Clear
};
ContentView.AddSubviews(new UIView[] {price, position, time});
}
开发者ID:JrRjChan,项目名称:FireWindforiOS,代码行数:29,代码来源:QuoteTableCustomCell.cs
示例8: SkipScanner
[Export("skipScanner:")] // notice the colon at the end of the method name
public NSString SkipScanner(NSString reportName)
{
//Task.Run(async () => { await App.XTCBackDoor.BackDoor()}).Wait();
return new NSString();
}
开发者ID:xamarin,项目名称:mini-hacks,代码行数:8,代码来源:AppDelegate.cs
示例9: LogInAndPay
public void LogInAndPay(NSString userName, NSString userPassword, string amount)
{
if (Payleven.LoginState == PLVPaylevenLoginState.PLVPaylevenLoginStateLoggedIn)
{
// Payleven: prepare device and make payment
PrepareDeviceAndPay (amount);
}
else
{
// Payleven: login user
Payleven.LoginWithUsername(userName, userPassword, new NSString (ApiKey), (errorHandler) =>
{
if (errorHandler == null)
{
// Payleven: login successful
PrepareDeviceAndPay(amount);
}
else
{
// Payleven: login failed
StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusLoginError);
}
});
}
}
开发者ID:Applandeo,项目名称:PaylevenSample,代码行数:25,代码来源:PaylevenManager.cs
示例10: ObserveValue
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
{
if (keyPath == "contentSize")
OnSizeChanged (new NSObservedChange (change));
else
base.ObserveValue (keyPath, ofObject, change, context);
}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:7,代码来源:ChatViewController.cs
示例11: GetPreferredFont
public static UIFont GetPreferredFont (NSString textStyle, float scale)
{
UIFontDescriptor tmp = UIFontDescriptor.GetPreferredDescriptorForTextStyle (textStyle);
UIFontDescriptor newBaseDescriptor = tmp.CreateWithSize (tmp.PointSize * scale);
return UIFont.FromDescriptor (newBaseDescriptor, newBaseDescriptor.PointSize);
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:7,代码来源:Font.cs
示例12: AddNotesCell
void AddNotesCell()
{
var cellIdentifier = new NSString("addBeerNotesCell");
var cell = TableView.DequeueReusableCell(cellIdentifier) as AddBeerNotesCell ??
new AddBeerNotesCell(cellIdentifier);
cells.Add(cell);
}
开发者ID:xmendoza,项目名称:BeerDrinkin,代码行数:7,代码来源:AddBeerTableViewController.cs
示例13: OnMessageReceived
public void OnMessageReceived(NSDictionary userInfo)
{
var parameters = new Dictionary<string, object>();
var json = DictionaryToJson(userInfo);
JObject values = JObject.Parse(json);
var keyAps = new NSString("aps");
if (userInfo.ContainsKey(keyAps))
{
NSDictionary aps = userInfo.ValueForKey(keyAps) as NSDictionary;
if (aps != null)
{
foreach (var apsKey in aps)
{
parameters.Add(apsKey.Key.ToString(), apsKey.Value);
JToken temp;
if (!values.TryGetValue(apsKey.Key.ToString(), out temp))
values.Add(apsKey.Key.ToString(), apsKey.Value.ToString());
}
}
}
CrossPushNotification.PushNotificationListener.OnMessage(values, DeviceType.iOS);
}
开发者ID:charri,项目名称:xamarin-plugins,代码行数:26,代码来源:PushNotificationImplementation.cs
示例14: IsEqualToString
public static bool IsEqualToString(this NSString text, NSString text2)
{
if (text == null || text2 == null)
return false;
return text.Value.Equals(text2.Value);
}
开发者ID:smartmobili,项目名称:CocoaBuilder,代码行数:7,代码来源:Extensions.cs
示例15: CreateImage
private UIImage CreateImage (NSString title, nfloat scale)
{
var titleAttrs = new UIStringAttributes () {
Font = UIFont.FromName ("HelveticaNeue", 13f),
ForegroundColor = Color.Gray,
};
var titleBounds = new CGRect (
new CGPoint (0, 0),
title.GetSizeUsingAttributes (titleAttrs)
);
var image = Image.TagBackground;
var imageBounds = new CGRect (
0, 0,
(float)Math.Ceiling (titleBounds.Width) + image.CapInsets.Left + image.CapInsets.Right + 4f,
(float)Math.Ceiling (titleBounds.Height) + image.CapInsets.Top + image.CapInsets.Bottom
);
titleBounds.X = image.CapInsets.Left + 2f;
titleBounds.Y = image.CapInsets.Top;
UIGraphics.BeginImageContextWithOptions (imageBounds.Size, false, scale);
try {
image.Draw (imageBounds);
title.DrawString (titleBounds, titleAttrs);
return UIGraphics.GetImageFromCurrentImageContext ();
} finally {
UIGraphics.EndImageContext ();
}
}
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:32,代码来源:TagChipCache.cs
示例16: SetLayoutIdentifierForArray
void SetLayoutIdentifierForArray (NSString identifier, NSArray constraintsArray)
{
for (nuint i = 0; i < constraintsArray.Count; i++) {
var constraint = constraintsArray.GetItem<NSLayoutConstraint> (i);
constraint.SetIdentifier (identifier);
}
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:7,代码来源:AstroViewController.cs
示例17: ExpenseViewCell
public ExpenseViewCell (NSString cellId)
: base(UITableViewCellStyle.Default, cellId)
{
date = new UILabel () {
Font = UIFont.FromName("AvenirNext-Medium", 10f),
TextAlignment = UITextAlignment.Left,
BackgroundColor = UIColor.Clear,
TextColor = UIColor.White
,
};
name = new UILabel () {
Font = UIFont.FromName("AvenirNext-Italic", 8f),
TextAlignment = UITextAlignment.Left,
BackgroundColor = UIColor.Clear,
TextColor = UIColor.White
};
amount = new UILabel () {
Font = UIFont.FromName("AvenirNext-Regular", 8f),
TextAlignment = UITextAlignment.Right,
BackgroundColor = UIColor.Clear,
TextColor = UIColor.White
};
ContentView.Add (date);
ContentView.Add (name);
ContentView.Add (amount);
}
开发者ID:McKabue,项目名称:TripXpense,代码行数:33,代码来源:ExpenseView.cs
示例18: Display
public void Display (string body, string title, GoalsAvailable goalAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
{
UIAlertView alert = new UIAlertView();
alert.Title = title;
alert.AddButton(acceptButtonTitle);
alert.AddButton(cancelButtonTitle);
alert.Message = body;
alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
alert.GetTextField(0).KeyboardType=UIKeyboardType.NumberPad;
const int maxCharacters =7;
alert.GetTextField(0).ShouldChangeCharacters = (textField, range, replacement) =>
{
var newContent = new NSString(textField.Text).Replace(range, new NSString(replacement)).ToString();
int number;
return newContent.Length <= maxCharacters && (replacement.Length == 0 || int.TryParse(replacement, out number));
};
alert.Clicked += (object s, UIButtonEventArgs ev) =>
{
if(action != null)
{
if(ev.ButtonIndex ==0)
{
string input = alert.GetTextField(0).Text;
int goalValue;
int.TryParse(input, out goalValue);
action.Invoke(goalAvailable, goalValue);
}
}
};
alert.Show();
}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:31,代码来源:InputGoalDialog.cs
示例19: UIViewElement
/// <summary>
/// Constructor
/// </summary>
/// <param name="caption">
/// The caption, only used for RootElements that might want to summarize results
/// </param>
/// <param name="view">
/// The view to display
/// </param>
/// <param name="transparent">
/// If this is set, then the view is responsible for painting the entire area,
/// otherwise the default cell paint code will be used.
/// </param>
public UIViewElement(string caption, UIView view, bool transparent)
: base(caption)
{
this.View = view;
this.Flags = transparent ? CellFlags.Transparent : 0;
key = new NSString("UIViewElement" + _count++);
}
开发者ID:acejack987,项目名称:CivicaGlossaryIOSApp,代码行数:20,代码来源:UIViewElement.cs
示例20: PatientCell
public PatientCell(UITableViewCellStyle style, NSString ident, Patient showSpeaker)
: base(style, ident)
{
SelectionStyle = UITableViewCellSelectionStyle.Blue;
nameLabel = new UILabel()
{
TextAlignment = UITextAlignment.Left,
Font = bigFont,
BackgroundColor = UIColor.FromWhiteAlpha(0f, 0f)
};
companyLabel = new UILabel()
{
TextAlignment = UITextAlignment.Left,
Font = smallFont,
TextColor = UIColor.DarkGray,
BackgroundColor = UIColor.FromWhiteAlpha(0f, 0f)
};
image = new UIImageView();
UpdateCell(showSpeaker);
ContentView.Add(nameLabel);
ContentView.Add(companyLabel);
ContentView.Add(image);
}
开发者ID:ewilde,项目名称:notes-for-nurses,代码行数:27,代码来源:PatientCell.cs
注:本文中的NSString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论