我使用以下代码突出显示所选标签标题。
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
以上代码完美无缺。我可以修改上面的代码来增加标签标题的字体大小并使其居中吗?
答案 0 :(得分:1)
本准则将为您提供帮助。
// set the text color for selected state
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName,[UIFont fontWithName:YOUR_FONT_NAME size:YOUR_FONT_SIZE],NSFontAttributeName ,nil] forState:UIControlStateSelected];
// set the text color for unselected state
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName,[UIFont fontWithName:YOUR_FONT_NAME size:YOUR_FONT_SIZE],NSFontAttributeName ,nil] forState:UIControlStateNormal];
//To make title center use below one
[[self.tabBarController.tabBar.items objectAtIndex:0] setTitlePositionAdjustment:UIOffsetMake(0, 0)];
[[self.tabBarController.tabBar.items objectAtIndex:1] setTitlePositionAdjustment:UIOffsetMake(0, 0)];
//if you have more tabs increase the index
答案 1 :(得分:1)
试试这个:
try
{
var query = from o in ctx.ORM
select new
{
id = o.id,
claim_no = o.claim_no,
emp_id = o.emp_id,
dept_id = o.dept_id,
location_id = o.location_id
};
}
catch (DbEntityValidationException ex)
{
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
var fullErrorMessage = string.Join("; ", errorMessages);
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
}